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',
$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