Support

Account

Home Forums General Issues WP_Query orderby date field does not work Reply To: WP_Query orderby date field does not work

  • I found the problem and resolved it.

    I was using a plugin which re-order the post-type I tried to call.
    This plugin is called Reorder-Post-Type.
    It seems to apply a filter on all queries that concerns a post-type affected by the plugin, even in your own code.

    If you want to prevent that, there’s a parameter that you can add in your query args, called ignore_custom_sort => true, like this :

        $args = array(
            'posts_per_page' => -1,
            'post_type' => 'post',
            'order' => 'DESC',
            'ignore_custom_sort' => true,
            'meta_key' => 'your_custom_field',
            'orderby' => 'meta_value'
        );