Viewing 6 replies - 1 through 6 (of 6 total)
  • Came here looking for the same thing, bizarre omission. Especially as the default seems to be order by date, which I presume is the date you added the member of staff?!

    Since this plugin seems to be unsupported I had a look at a workaround. You can change the default order by editing the following;

    /public/includes/class-cherry-team-data.php
    LINES 68,69
    ‘orderby’ => ‘title’,
    ‘order’ => ‘ASC’,

    So the above would be order by their name. ‘orderby’ values are pretty limited at the moment. ‘none’,’ID’,’author’,’title’,’date’,’modified’,’parent’,’rand’,’comment_count’,
    ‘menu_order’,’meta_value’,’meta_value_num’

    Would be nice to update the shortcode to get Order and OrderBy passed through, but I’m just trying to built a website, not code a plugin too so a workaround suits me.

    • This reply was modified 7 years, 1 month ago by jmzwiv.
    ADT

    (@adwaitatechnologies)

    @jmzwiv, you’re a lifesaver!! many thanks for this small code change ??

    ADT

    (@adwaitatechnologies)

    However, I noticed the sorting works only for the group which was created first. other groups do not pick up the change.

    • This reply was modified 6 years, 10 months ago by ADT.

    Thank you jmzwiv. This gave me the idea to edit the “Published On” date to match the order I wanted the people to sort.

    I would like to be able to change this without changing the plugin. Does anyone know how we can do this via functions.php?

    I’ve got a solution for this that doesn’t require editing core plugin files. You just need to add the code below to your child theme’s functions.php and then edit the orderby and order values as you wish.

    add_action( 'pre_get_posts', 'modify_team_query' );
    function modify_team_query( $query ) {
    
        // Check if on frontend and query post_type is team
        if( ! is_admin() && $query->is_main_query() && $query->query_vars['post_type'] = 'team' ) {
    
            $query->set('orderby','title');
            $query->set('order', 'ASC');
        }
    }

    Thanks to the community at StackOverflow for helping me iron out a couple of bugs.

    In addition, I also made a way to sort by last name, but that requires using Advanced Custom Fields PRO and an additional tweak to this code. Hope this helps someone!

    • This reply was modified 6 years, 4 months ago by bobbybosler.
    • This reply was modified 6 years, 4 months ago by bobbybosler.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘sort team members?’ is closed to new replies.