0

hello i just added date input by using metabox but i can't sort the loop in the front end page by latest metabox input date i try this

$args = array(
'post_type'  => 'post',
'meta_key'       => 'meta_date', 
'meta_value_num' => ,
);
query_posts($guide); if(have_posts()){
 while(have_posts()) : the_post();
 echo get_the_title();
 endwhile;
}

but doesn't work for me , is there anyway to do that by using loop,thanks

0

Have you tried passing in the $args variable to query_posts, rather than $guide?

query_posts($args);

Also, you should be looking to create the custom query using WP_Query class and not the query_posts. See this answer for more details (https://wordpress.stackexchange.com/a/1755)

Try the below code:

$args = array('post_type'  => 'post', 'meta_key' => 'meta_date', 'meta_value_num' => , );

$my_query = new WP_Query( $args );

if($my_query->have_posts() { 
    while($my_query->have_posts()) : $my_query->the_post();
          echo get_the_title();
    endwhile;
}

Also, please see the following: Order custom posts by a date metabox.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.