Support » Plugin: Toolset Types - Custom Post Types, Custom Fields and Taxonomies » Sort query by custom meta field

  • Resolved Soulcyber

    (@soulcyber)



    Hi guys, i’ve created a new CPT with Types plugin and added a checkbox in custom fields named “wpcf-evidenza”.

    Now i need to query my CPT “hotel” and sort the query posts based on the checkbox’s value, (1 checked, 0 otherwise).

    hotels with checked checkbox should appear before the others, i’ve followed a lot of discussion about this thing and the most part of users with the same problem have solved with a query very similar to this:

    query_posts(array(
    'post_type' => 'hotel',
    'posts_per_page' => 3,
    'paged' =>$paged ,
    'meta_key' => 'wpcf-evidenza',
    'orderby' => 'meta_value_num' ,
    'order' => 'DESC'
    ));

    But seems not working for me, what could be the problem?

    Thank You 🙂

    https://wordpress.org/plugins/types/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sort query by custom meta field’ is closed to new replies.