Custom query with meta_key not working fine

Question

I’m making the following query in order to get all the posts sorted by a meta key (wpcf-estado in this case) but it returns the items in no order:

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        $args = array( 
                        'post_type' => 'proyectos',
                        'posts_per_page' => 8,
                        'paged' => $paged,
                        'orderby' => 'meta_value',
                        'order' => 'DESC',
                        'meta_key' => 'wpcf-estado',
                        //'meta_value' => 'a',                                      
        );

If I uncomment the ‘meta_value’ parameter, I end up succesfully getting only the posts containing ‘a’ as wpcf-estado.

The possible values of wpcf-estado are: a, b or c.

I tried several things but didn’t find a proper solution.

0
Rod0n 5 months 2020-12-25T12:10:18-05:00 0 Answers 4 views 0

Leave an answer

Browse
Browse