0
global $wp_query;
$args = array_merge( $wp_query->query_vars, array( 'meta_query' => array(
    array('key' => 'release_date',),)
    ,    'orderby' => 'release_date title','order' => 'DESC',  ) );


query_posts( $args );

I'm sorting my post with post that have release_date value, however post that don't have release_date value are not showing, I wish to add them to the list or do I have to edit all my post to add a value in it? I'm currently using the above code.

Any help would be appreciated.

Thanks!

5
  • May be this will help you a bit : wordpress.stackexchange.com/a/55791/116990
    – inrsaurabh
    Commented Jan 8, 2021 at 4:45
  • You'd want to add a second meta query clause with compare set to NOT EXISTS - see my answers here and/or here. And please, avoid using query_posts() - use the pre_get_posts hook if you wish to modify the main WordPress query.
    – Sally CJ
    Commented Jan 8, 2021 at 4:45
  • @inrsaurabh thank you, i will look into it. Commented Jan 8, 2021 at 10:03
  • @SallyCJ I'm just adding additional args for the query post, as I can't find on my themes where the query post, i will check pre_get_posts thank you. Commented Jan 8, 2021 at 10:04
  • 1
    @SallyCJ the relation and compare works for me, thank you so much. Commented Jan 8, 2021 at 10:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.