我在模板上有这个功能
function wp_posts( $layout = 'blog-posts' ) {
if ( have_posts() ) :
$i = 1;
while ( have_posts() ) : the_post();
do_action('fwp_before_post_content');
get_template_part('extend-helpers/' . $layout);
do_action('fwp_after_post_content');
$i++;
endwhile;
else:
get_template_part('extend-helpers/content', 'none');
endif;
}
如何按照我想要的ID对帖子进行排序?
答案 0 :(得分:0)
试试这个:
<?php
function wp_posts( $layout = 'blog-posts' ) {
global $query_string;
query_posts($query_string . '&orderby=id&order=ASC');
if ( have_posts() ) :
$i = 1;
while ( have_posts() ) : the_post();
do_action('fwp_before_post_content');
get_template_part('extend-helpers/' . $layout);
do_action('fwp_after_post_content');
$i++;
endwhile;
else:
get_template_part('extend-helpers/content', 'none');
endif;
}
?>
答案 1 :(得分:0)
下面的代码将显示自定义帖子类型&#34;推荐&#34; ID按降序排列
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query(); $wp_query->query('post_type=testimonial&post_status=publish&showposts=4&orderby=ID&order=DESC' . '&paged='.$paged);
while ($wp_query->have_posts()) :
$wp_query->the_post();
endwhile;