Home › Forums › Pro Version › Custom Query – how to use / to show different order?
Tagged: Custom Query
- This topic has 5 replies, 2 voices, and was last updated 5 years, 5 months ago by
snikay.
- AuthorPosts
snikay
ParticipantHi!
Really, I hate to bother you again.. I tried the whole day to get „wpeddit_order“ working with custom query-field. But I failed. Also checked your documentation and wordpress core but I think I just don’t understand what I have to do to get wpeddit_order working again. Could you please help me out again?Thanks!
PS: ignore my email, think it’s a question for the forum 🙂
Masonry Guy
KeymasterHi Snikay,
This is the code you need to set right ?
$query->set('meta_key', 'epicredrank'); $query->set('orderby', 'meta_value_num'); $query->set('order', 'DESC');
So please keep this in custom query field in your shortcode.
meta_key=epicredrank&orderbymeta_value_num&order=DESC
Hope this helps.
snikay
ParticipantHm, if i just paste this into the custom query field, the order still is by date/last posts.
This is the code I had to put into the functions.php:
//code for changing the custom post order function wpeddit_order($query) { global $wp_query; if ( ! $query->is_main_query() ) return $query; if(!is_page() || !is_admin()){ if(is_main_query()){ $query->set('meta_key', 'epicredrank'); $query->set('orderby', 'meta_value_num'); $query->set('order', 'DESC'); } } return $query; } add_action('pre_get_posts','wpeddit_order');
snikay
ParticipantOh! NOW I understood how this works! The
=
was missing;meta_key=epicredrank&orderby=meta_value_num&order=DESC
Thanks, D! 🙂
Masonry Guy
KeymasterGlad it is fine for your now.
If you have a few mins for us, can you please write us a review for our plugin at https://wordpress.org/support/view/plugin-reviews/wp-masonry-layout?filter=5? This will help us grow and makes easier for others to decide to use the plugin.
Thanks
snikay
ParticipantI already rated it over there 🙂 We talked about that in the emails as we were talking about WPeddit.
- AuthorPosts