Archive display sorting

This topic contains 11 replies, has 3 voices, and was last updated by  Stiofan O’Connor 6 years, 8 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: ,

  • Author
    Posts
  • #391991

    Mitch Canton
    Expired Member
    Post count: 167

    This plugin has made my life easier in numerous ways, so the Pro upgrade was a great purchase, thanks for that.

    There’s one glaring issue I can’t get my arms around to resolve though.

    We, I assume like many others, have Regular listings and Featured listings. When a user hits a link to a category of listings – the way the display of those listings is determined gives me, and my clients and users, fits.

    If we set “Featured” to be the default sorting, the first couple Featured are listed, and then dozens more regular listings are listed in a terribly frustrating manner (which I believe is based on order entry date or update date?) with P’s followed by B’s followed by W’s followed by D’s… (you get the point). Very unfriendly to a user who has been conditioned for years that things are A-Z.

    Now we can do A-Z as default, but then my paying Featured clients that start with ‘R’ or ‘T’ are none too pleased with having dozens of listings displayed above them.

    Is there not any way we can set the ‘secondary’ sort of these listings? Or maybe have the archive page have two sections “Featured” then “A-Z”?

    Thanks for your feedback or ideas on what we could do to work around this.

    Have a great day.

    #392002

    Guust
    Moderator
    Post count: 29970

    You can set the sorting options to be Featured by default, and then add any other sort for visitors to execute themselves.
    See also https://wpgeodirectory.com/docs/core-place-settings/#sorting

    Thanks

    #392079

    Mitch Canton
    Expired Member
    Post count: 167

    I understand those options, thank you. And I thought of setting it to Featured first, and allowing for user to change.

    But in a perfect world, I was looking for a way to have the archive automatically do a second sort, and understanding that that might be too complex, simply a way to have the category/archive page display ‘two’ sets of records – one that was Featured only on top, and then all the records related to that category/archive under those on the page.

    I used to do that on a custom page with shortcodes with the other directory plugin I used (and I assume I could do the same with WPGD) but I didn’t want to set up page redirects on all the category URL’s – that’s just a pain.

    Any other thoughts on how I might accomplish this? Maybe a template mod? Or?

    Thanks in advance.

    #392120

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    How would u want them sorted?
    You could modify the query or you could add a shortcode above the listings to show featured there.

    Stiofan

    #392209

    Mitch Canton
    Expired Member
    Post count: 167

    Is it possible to add a shortcode to display before the return of the full category archive display?

    Where if someone clicked a link to CategoryA, the returned listings page would display the Featured listings in CategoryA first (at the top), then all of the listings in CategoryA beneath that, and the display of both would be default as A-Z. It would even be fine if a user could not modify the sort of the Featured group (left as A-Z), but just could select the sort of the regular (all listings in that CategoryA) query display.

    I assume that this would be in the listing-listview.php file?

    Something placed around do_action(‘geodir_before_listing_listview’); ?

    I’m guessing here 🙂 so guidance is appreciated.

    Thanks.

    #392218

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    There is no exact way to do what you want just now, i’ll look at this tomorrow and see if i can think of an exact solution.

    Thanks,

    Stiofan

    #392219

    Mitch Canton
    Expired Member
    Post count: 167

    Thank you in advance for considering how we might accomplish this. Appreciated.

    Have a great day.

    #392275

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    OK, this will show what you want above the regular listings:

    
    
    add_action('geodir_before_listing','_my_listings_top');
    function _my_listings_top(){
    
    	global $wp_query;
    	$current_term = $wp_query->get_queried_object();
    	$cat_id = isset($current_term->term_id) ? $current_term->term_id :'';
    	$post_type = geodir_get_current_posttype() ? geodir_get_current_posttype() : 'gd_place';
    
        echo "<h3>Featured listings</h3>";
    	echo do_shortcode('[gd_listings post_type="'.$post_type.'" layout=5 category="'.$cat_id.'" post_number="4" list_sort="high_review" show_featured_only=1 ]');
    }

    This solution will order the listings how you want, i think you would prefer this one:
    For this to work you would need to go to GD>Place Settings>Sorting Options: and set the default to featured.

    
    
    add_filter('geodir_posts_order_by_sort','_my_custom_order_by',10,3);
    function _my_custom_order_by($orderby, $sort_by, $table){
    	global $wpdb;
    
    	if($sort_by=='is_featured_asc'){
    		$orderby .= " $wpdb->posts.post_title ASC, ";
    	}
    	return $orderby;
    }

    If you have any problems just let me know.

    Thanks,

    Stiofan

    #392336

    Mitch Canton
    Expired Member
    Post count: 167

    Hey Stiofan,

    These are fantastic, thank you. I’ve tested both and they work exactly like I would have envisioned. I see where the second one is perfect for sorting the Featureds, then AZ, in the same layout, but I actually like the layout of the first one with the separation between the listings sections. I’m going to test both more and see which sticks with me.

    Only one thing I’d inquire about on the first solution; is there a way to remove the display of anything if the query returns that there are “No listings found which match your selection.” ?

    Again, this is great stuff, thank you for your assistance in finding a solution. Hopefully others looking for the same ability to highlight Featureds without eliminating an alpha sort will find this helpful.

    #392339

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    This would achieve that:

    
    
    add_action('geodir_before_listing','_my_listings_top');
    function _my_listings_top(){
    
    	global $wp_query;
    	$current_term = $wp_query->get_queried_object();
    	$cat_id = isset($current_term->term_id) ? $current_term->term_id :'';
    	$post_type = geodir_get_current_posttype() ? geodir_get_current_posttype() : 'gd_place';
    
    	$output = do_shortcode('[gd_listings post_type="'.$post_type.'" layout=5 category="'.$cat_id.'" post_number="4" list_sort="high_review" show_featured_only=1 ]');
    
    	if (strpos($output, 'no-listing') === false) {
    		echo "<h3>Featured listings</h3>";
    		echo $output;
    	}
    
    }

    Thanks,

    Stiofan

    #392373

    Mitch Canton
    Expired Member
    Post count: 167

    Excellent. I simply tweaked the shortcode some for the ‘Featureds’ layout and character_count, and added

    echo "<hr /><h4>More GoLocal Listings</h4>";

    after the

    echo $output;

    as a ‘transition/intro’ to the complete listings (featured and non-featured), and it’s perfect for what I was looking for.

    Thanks again. You guys are the best.

    #392378

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    You are welcome! 🙂

Viewing 12 posts - 1 through 12 (of 12 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket