我正在尝试按照ASC顺序对ID进行排序,我可以在使用单个查询时执行此操作但是在使用数组查询时我无法按照ASC顺序对ID进行排序,我的代码如下所示
<?php endwhile; else : ?>
<p><?php esc_html_e( 'Sorry, no results matched your criteria.' ); ?</p>
<?php endif; ?>
<li><?php
echo paginate_links(array(
'total' => $newposts->max_num_pages
));
?></li>
//一些显示代码和关闭代码//
之后my_list = [1,2,3]
d = {'word': my_list}
答案 0 :(得分:0)
WordPress按类别名称查询
<?php $args = array(
'posts_per_page' => 5,
'offset' => 0,
'category' => '',
'category_name' => '',
'orderby' => 'date',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' => '',
'post_type' => 'post',
'post_mime_type' => '',
'post_parent' => '',
'author' => '',
'author_name' => '',
'post_status' => 'publish',
'suppress_filters' => true
);
$posts_array = get_posts( $args ); ?>
// Custom query.
$query = new WP_Query( $args );
// Check that we have query results.
if ( $query->have_posts() ) {
// Start looping over the query results.
while ( $query->have_posts() ) {
$query->the_post();
// Contents of the queried post results go here.
}
}
希望这适合你。