admin管理员组文章数量:1425717
In wordpress query, Can I single out the specific post by index number of the query result?
for example
<?php
$args = array(
'post_type' => 'headimages',
'orderby' => 'menu_order',
'order' => 'ASC'
);
$package_query = new WP_Query( $args );
$num = $package_query->post_count; ?>
so how do i display the second result or third result from this query? Can I do something like this?
<php $thirdresult = $package_query[2];>
please help.
In wordpress query, Can I single out the specific post by index number of the query result?
for example
<?php
$args = array(
'post_type' => 'headimages',
'orderby' => 'menu_order',
'order' => 'ASC'
);
$package_query = new WP_Query( $args );
$num = $package_query->post_count; ?>
so how do i display the second result or third result from this query? Can I do something like this?
<php $thirdresult = $package_query[2];>
please help.
Share Improve this question asked May 29, 2019 at 7:17 EnamEnam 133 bronze badges1 Answer
Reset to default 0The results of a query are stored as an array in the $posts
property of the query object, so you can access the third result like so:
$package_query = new WP_Query( $args )
$third_result = $package_query->posts[2];
本文标签: Access Wordpress query by index number outside the loop
版权声明:本文标题:Access Wordpress query by index number outside the loop 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745454310a2659030.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论