sort page isn't working
-
Hi,
I made a custom query to show the thubmnail of pages with a specific meta_value ordred by a specific order.
But my script does not seems to be working..
The code
$args = array( 'post_type' => 'page', 'post_parent' => '8', 'sort_column' => 'ID', 'meta_key' => 'concours_ou_promotion', 'meta_value' => 'promotion', 'sort_order' => 'ASC' ); query_posts($args); // The Loop while ( have_posts() ) : the_post(); ?> <a href="#"><?php the_post_thumbnail( array(564,255) ); ?></a> <? endwhile; // Reset Query wp_reset_query();What I want to do
I would like to order these post by creation date or post ID (same as creation date). But whatever I do, it’s always the last page that is visible the first.Can some one help me fix this script?
Can anywone help me?
-
Just resolved it by myself.
Actually, I was writting some types of fields that are only used in wp_list_pages()
So I search arround and here is my new version of array :
My code
$args = array( 'post_type' => 'page', 'post_parent' => '8', 'meta_key' => 'concours_ou_promotion', 'meta_value' => 'promotion', 'order' => 'ASC' );I am still open to comments/suggestions to get a better and clear code.
'sort_column'should be'orderby'(‘date’ or ‘ID’ are both valid) and'sort_order'should be'order'(either ‘ASC’ or ‘DESC’).EDIT: You just beat me to it, glad you sorted it.
@duck__boy : Thx for the orderby
The last code should be :
$args = array( 'post_type' => 'page', 'post_parent' => '8', 'meta_key' => 'concours_ou_promotion', 'meta_value' => 'promotion', 'orderby' => 'ID', 'order' => 'ASC' );
The topic ‘sort page isn't working’ is closed to new replies.