kylephillips / favorites

Simple and flexible favorite buttons for any WordPress post type.
https://favoriteposts.com
223 stars 86 forks source link

Any way to sort posts by no. of favorites? #88

Open aliguy opened 6 years ago

gfargo commented 6 years ago

Hey @aliguy,

This should be possible with a custom WP_Query that contains a meta_query for the simplefavorites_count metadata value.

e.g.

$query = new WP_Query( [
        'post_type' => 'post',
    'orderby'   => 'meta_value_num',
    'meta_key'  => 'simplefavorites_count',
] );

You can take a look at custom field parameters for the WP_Query class for more information.

note: haven't had a chance to personally test this code, but in theory, it should work 💭