admin管理员组文章数量:1386695
I have custom post type 'movies' listing which i want to order by title, descending. Currently it sorts by post id. The code is:
<?php
if( $movies->have_posts() ) : while( $movies->have_posts() ) : $movies->the_post();
$post_id = get_the_ID();
$the_movie = TMDB()->get_movie_details( $post_id );
?>
I tried adding several things, like:
<?php
query_posts(array(
'post_type' => 'movies',
'orderby' => 'title'
) );
?>
And also:
<?php query_posts($query_string . '&orderby=title&order=ASC');?>
So far without succes. I am missing something. Who can help a php newbie out here?
I have custom post type 'movies' listing which i want to order by title, descending. Currently it sorts by post id. The code is:
<?php
if( $movies->have_posts() ) : while( $movies->have_posts() ) : $movies->the_post();
$post_id = get_the_ID();
$the_movie = TMDB()->get_movie_details( $post_id );
?>
I tried adding several things, like:
<?php
query_posts(array(
'post_type' => 'movies',
'orderby' => 'title'
) );
?>
And also:
<?php query_posts($query_string . '&orderby=title&order=ASC');?>
So far without succes. I am missing something. Who can help a php newbie out here?
Share Improve this question asked Apr 16, 2020 at 12:25 njinoknjinok 11 bronze badge 5 |1 Answer
Reset to default -2I think the part you are just missing order. Try this:
'post_type' => 'movies',
'orderby' => 'title',
'order' => 'ASC',
本文标签: wp queryhaveposts order by title descending
版权声明:本文标题:wp query - have_posts order by title descending 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744561991a2612817.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
$movies
coming from? – Jacob Peattie Commented Apr 16, 2020 at 13:10$movies
to query posts. You must have defined it somewhere? – Jacob Peattie Commented Apr 16, 2020 at 13:14$args
? – Jacob Peattie Commented Apr 16, 2020 at 14:03