Forums Forums Search & Filter Pro post types in alphabetical order

Viewing 9 posts - 1 through 9 (of 9 total)
  • Anonymous
    #70952

    we are using the Search and filter for several post types and it is working magnificently! (also got masonry working for the results!)

    The question I would like to ask, is:

    Can we reorder the post types into alphabetical order?
    (I can provide a link if need be)
    We are using AJAX results using the shortcode.

    Thank you for your time, and such a great plug in!

    Trevor
    #70986

    I am not sure how you might go about this, so I will have to ask Ross. Others reading this might be interested in the code you used to get masonry working? If you can post it here, in between code tags (in the formatting bar above).

    Anonymous
    #71049

    I would have to say that I did try to change the order of the custom post types by changing their menu positions.(5-100) and that did not work, but thought it might since they are in the order that they are in my admin menu. Maybe that will help Ross.

    Anonymous
    #71051

    This is how I got the masonry working:

    (function ( $ ) {
    	
    	"use strict";
    
    	$(function () {
    		//detects the start of an ajax request being made
    		$(document).on("sf:ajaxstart", ".searchandfilter", function(){
    		  console.log("ajax start");
    
    		});
    
    		//detects when the ajax request has finished and the content has been updated
    		// - add scripts that apply to your results here
    		$(document).on("sf:ajaxfinish", ".searchandfilter", function(){
    			console.log("ajax complete");
    
    $('#ms-container').imagesLoaded( function() {
    var container = document.querySelector('#ms-container');
    var msnry = new Masonry( container, {
    itemSelector: '.ms-item',
    columnWidth: '.ms-item',                
    isAnimated: true,
            });
    });
    // this is to change the text label in search box --this can be omitted
    $('label.sf-label-checkbox').each(function() {
        var text = $(this).text();
        $(this).text(text.replace('TL Articles', 'Thought Leadership')); 
    });  
    // end of change the text label in search box --this can be omitted
          console.log("masonry complete");
    			//so load your lightbox or JS scripts here again
    		});
    
    		//an event fired when S&F is initialised and S&F scripts have been loaded
    		$(document).on("sf:init", ".searchandfilter", function(){
    			console.log("S&F JS initialised");
    
    		});
    	});
    			
    }(jQuery));
    Trevor
    #71057

    Cool. Thanks.

    Anonymous
    #72621

    Any update on being able to list post typed alphabetically?

    Anonymous
    #72714

    Do you happen to know where these are called in?

    I believe it is currently being populated by Post Type ID. (or is the way that WordPress does it), and I would think that this could be done kind of easily, (but I am no WP or Search and Filter expert)

    Is it in post_type.php, in the public > includes > fields directory?

    I found this code online, but am not sure how to apply it, but you guys might!

    add_action( 'pre_get_posts', custom-post-slug_order' );
        /**
         * Change order of custom post type to alphabetical ascending 
         */  
        function custom-post-slug_order( $query ) {
            // check if we're in admin, if not exit
            if ( ! is_admin ) {
                return;
            }
    
            $post_type = $query->get('post_type');
    
            if ( $post_type == custom-post-slug) {
                /* Post Column: e.g. title */
                if ( $query->get( 'orderby' ) == '' ) {
                    $query->set( 'orderby', 'title' );
                }
                /* Post Order: ASC / DESC */
                if( $query->get( 'order' ) == '' ){
                    $query->set( 'order', 'ASC' );
                }
            }
        }
    

    I hope to get this working as soon as possible.

    Anonymous
    #72872

    After looking into getting this working sooner, than later, I found a solution!
    A small little JS plugin called Tiny Sort.
    Once the js file is loaded, I used the following code within the sf-pro-ajax-events.js file:

    $(function() {
    tinysort('ul>li.sf-level-0');
    console.log("tiny sort restarted after ajax");
    });

    This will load anytime after the ajax has finished.

    You can get the tiny sort code here:
    tinysort.sjeiti.com

    Trevor
    #72890

    Cool. I will close this for now then.

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