Genesis – Set the Portfolio order

Many WordPress StudioPress Themes include a Portfolio. A need I had recently was to order the Portfolio items alphabetically as the default is to order by Post number. There are no options in the Genesis dashboard settings but fortunately its really simple to order the portfolio alphabetically.

Instructions to set Portfolio sort order

To set the StudioPress Genesis Portfolio sort order to be alphabetical:

  1. Open the child Theme functions.php for editing
  2. Change the following
    /** Change the number of portfolio items to be displayed (props Bill Erickson) */
    add_action( 'pre_get_posts', 'executive_portfolio_items' );
    function executive_portfolio_items( $query ) {
    
    if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
    $query->set( 'posts_per_page', '12' );
     }
    
    }
    
    

    to

    /** Change the number of portfolio items to be displayed (props Bill Erickson) */
    add_action( 'pre_get_posts', 'executive_portfolio_items' );
    function executive_portfolio_items( $query ) {
    
    if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
     $query->set( 'orderby', 'title' );
    $query->set( 'order', 'ASC' );
     $query->set( 'posts_per_page', '12' );
     }
    
    }
  3. Save the changes.

The Portfolio will now show in alphabetical order.

Comments

  1. Woohoo says

    Hi Gary,
    Awesome!
    But is this sorting also possible with a custom field, with name ‘team’ and a value of ’1′ (and going up).

  2. Woohoo says

    Oh, and do you know how to change the default name ‘portfolio’ to something else so the url of this page would look something like ‘mydomain.com/team’ instead of ‘mydomain.com/portfolio’

  3. Woohoo says

    Gary,
    One thing puzzles me.
    When I set the order to ‘ASC’ the result on the page gets all mixed up: Items 1 2 and 3 get properly aligned after each other in one row, Item 4 goes all the way to the right on the second row and the last item (5) is on the third row on the left.
    But when I set the order to ‘DESC’ everything looks good: row 1 contains three items, and row two contains 2 items, all properly aligned after each other (in CSS there is a float: left to accomplish this).
    So, without altering the CSS the placement of the 5 items varies upon switching from ‘ASC’ to ‘DESC’.
    This is weird.

    • Woohoo says

      Don’t bother, it has everything to do with the length (number of lines and characters) of the paragraph of each portfolio item.

Australian WordPress Specialist

Australian WordPress Specialists.

OrganicWeb provides leading WordPress solutions. Specialities include developing high converting Websites built with SEO from the ground up. Contact us to get more customers from your Website.

Leave a Reply