• Resolved WTadmin

    (@wtadmin)


    Hi there,

    I need to sort all testimonials so they appear in the ‘View’ alphabetically by ‘Title’.

    I tried using the ‘Menu Order’ sort option, however I have hundreds of testimonials and I will have to manually reorder each entry into alphabetical each time. This will be very time consuming.

    Is there another way?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Chris Dillon

    (@cdillon27)

    To sort all views alphabetically, add this to your theme’s functions.php or create an mu-plugin.

    /**
     * Sort testimonials alphabetically.
     */
    function my_testimonials_orderby( $args, $atts ) {
    	$args['orderby'] = 'post_title';
    	return $args;
    }
    add_filter( 'wpmtst_query_args', 'my_testimonials_orderby', 10, 2 );

    To sort a specific view only; for example, view id 2:

    /**
     * Sort testimonials alphabetically.
     */
    function my_testimonial_view_query( $args, $atts ) {
    	if ( 2 == $atts['view'] ) {
    		$args['orderby'] = 'post_title';
    	}
    	return $args;
    }
    add_filter( 'wpmtst_query_args', 'my_testimonial_view_query', 10, 2 );
    

    I added this line to ensure sorting ascending:

    $args['order'] = 'ASC';

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sort Testimonials Alphabetically’ is closed to new replies.