Topic: Custom Query – how to use / to show different order? | WP Masonry Layout

Custom Query – how to use / to show different order?

Home Forums Pro Version Custom Query – how to use / to show different order?

Tagged: 

This topic contains 5 replies, has 2 voices, and was last updated by  snikay 1 year, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #6396 Reply

    snikay
    Participant

    Hi!
    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 🙂

    #6405 Reply

    Masonry Guy
    Keymaster

    Hi 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.

    #6412 Reply

    snikay
    Participant

    Hm, 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');
    #6413 Reply

    snikay
    Participant

    Oh! NOW I understood how this works! The = was missing;

    meta_key=epicredrank&orderby=meta_value_num&order=DESC

    Thanks, D! 🙂

    #6415 Reply

    Masonry Guy
    Keymaster

    Glad 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

    #6421 Reply

    snikay
    Participant

    I already rated it over there 🙂 We talked about that in the emails as we were talking about WPeddit.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Custom Query – how to use / to show different order?
Your information: