sebathustra

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: Sorting for Listing #43883

    sebathustra
    Buyer
    Post count: 1

    Hallo,

    I would like to sort first always the featured customers randomly and after them there should be the free listings also randomly sorted.

    Is it possible to modify Vikas’ code to achieve this effect?

    
    
    add_filter('pre_get_posts', 'geodir_apply_my_posts_orderby');
    function geodir_apply_my_posts_orderby($query)
    {
    	if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
    		if(!is_admin())
    			add_filter('posts_orderby', 'geodir_my_posts_orderby'  );
    	}
    
    }
    
    function geodir_my_posts_orderby($orderby)
    {
    	global $wpdb;
    	if(!is_admin())
    	{
    		$orderby = str_replace(", $wpdb->posts.post_date desc" , '', 	$orderby);
    	}
    	return $orderby ;
    	
    }
Viewing 1 post (of 1 total)
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount