• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

(Pretty Creative) Order of Portfolio Page Items

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › (Pretty Creative) Order of Portfolio Page Items

This topic is: not resolved

Tagged: Portfolio CPT, pre_get_posts, Pretty Creative

  • This topic has 7 replies, 3 voices, and was last updated 9 years, 7 months ago by paulag01.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • April 28, 2016 at 3:54 pm #184638
    paulag01
    Member

    I am using the Pretty Creative Theme for a new site (URL below)

    I am using a custom field called portfolio-order to order the 6 portfolio items on the home page. That works as it should.

    On the Portfolio Archive Page (Which I am linking to from the Samples nav menu item) - I cannot control the # of items displayed or the order. (http://karinrex.com/newsite/portfolio/)

    How can I simply display them in the same order as the home page? There is no "settings" page in the Portfolio feature.

    http://karinrex.com/newsite
    April 28, 2016 at 9:34 pm #184655
    Doug Edgington
    Member

    I haven't used this theme. But you should be able to control the order by modifying the post dates. They likely display in descending order - most recent date first.

    In regards to controlling the number of portfolio items, you can go to settings-->reading and set "Blog pages show at most" to the desired setting. But this will also affect your blog. If you need to single out the portfolio section separate from the blog, you could use code like the example below to modify the query. The example assumes the post type name is portfolio. The code would need to be placed in the functions.php file.

    //* Change the number of portfolio items to be displayed to 9
    add_action( 'pre_get_posts', 'dee_portfolio_count' );
    function dee_portfolio_count( $query ) {
    
    	if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
    		$query->set( 'posts_per_page', '9' );
    	}
    
    }

    Doug Edgington
    http://www.dougedgington.com

    April 29, 2016 at 6:18 am #184674
    paulag01
    Member

    Thanks Doug. The reading setting for blogs worked like a charm. She isn't going to have a regular blog so it works.

    My bigger concern is the display order. Basically one portfolio item for each area of her business service. So each time she would add/update something, it would change the order. What she really wants is a set order all the time (regardless of last updated date). Is there any way to have it order differently (by a custom field or similar)?

    Thanks
    Paula

    April 29, 2016 at 8:31 am #184684
    Doug Edgington
    Member

    You could modify the query to display by menu_order rather than the date. And you could then set the "order field" in the attributes box for each post.

    If you have a taxonomy applied to the portfolio custom post type, you can also categorize the portfolio posts like would a blog. Not sure if this would help out in any way with what you are doing.


    Doug Edgington
    http://www.dougedgington.com

    April 30, 2016 at 12:26 am #184725
    Brad Dalton
    Participant

    Is there any way to have it order differently (by a custom field or similar)?

    You can use the custom field parameters from WP_Query as seen here


    Tutorials for StudioPress Themes.

    May 2, 2016 at 9:06 am #184802
    paulag01
    Member

    Thank you Brad and Doug for the info.

    So Brad, if I am tracking right with your response, I would need to make a change to the php that generates the blog posts for that page then.

    But I am not sure syntactically how to handle adding in an order and orderby parameter to what exists there. Can I just add an $order and $orderby parameter, but then how does it get recognized by the $wp_query (or does it happen automatically).

    Like
    'meta_key' => 'portfolio-order',
    'orderby' => 'meta_value',
    'order' => 'ASC',

    function be_portfolio_post_class( $classes ) {
    if ( is_main_query() ) { // conditional to ensure that column classes do not apply to Featured widgets
    $columns = 3; // Set the number of columns here
    $column_classes = array( '', '', 'one-half', 'one-third', 'one-fourth', 'one-fifth', 'one-sixth' );
    $classes[] = $column_classes[$columns];
    global $wp_query;
    if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % $columns )
    $classes[] = 'first';
    }
    return $classes;

    ---

    One of these great "template only" jobs turned.... but can we customize this? Scenarios.

    Any insight much appreciated.

    Thanks
    Paula

    May 2, 2016 at 5:29 pm #184851
    Brad Dalton
    Participant

    Use the code Doug posted and add the order and orderby parameters.

    Something like this:

    //* Change the number of portfolio items to be displayed to 9
    add_action( 'pre_get_posts', 'dee_portfolio_count' );
    function dee_portfolio_count( $query ) {
    
    	if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
    		$query->set( 'posts_per_page', '9' );
                    $query->set('meta_key', 'portfolio-order' );
                    $query->set('orderby', array('meta_value' => 'ASC', 'date' => 'DESC'));
    	}
    
    }
    

    You could also add is_home() to the conditional checks.

    Untested.


    Tutorials for StudioPress Themes.

    May 3, 2016 at 11:22 am #184908
    paulag01
    Member

    Thanks for these. I did give this a whirl with a few edits but couldn't seem to make it change the order.

    Maybe I just need to try it on another test site at some point....

    //* Change the number of portfolio items to be displayed to 9

    function dee_portfolio_count( $query ) {

    if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
    $query->set( 'posts_per_page', '6' );
    $query->set('meta_key', 'portfolio-order' );
    $query->set('orderby', array('meta_value_num' => 'ASC', 'date' => 'DESC'));
    }
    return $query;
    }

    add_action( 'pre_get_posts', 'dee_portfolio_count' );

    /**
    * Display as Columns
    *
    */
    function be_portfolio_post_class( $classes ) {
    if ( is_main_query() ) { // conditional to ensure that column classes do not apply to Featured widgets
    $columns = 3; // Set the number of columns here
    $column_classes = array( '', '', 'one-half', 'one-third', 'one-fourth', 'one-fifth', 'one-sixth' );
    $classes[] = $column_classes[$columns];
    global $wp_query;
    if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % $columns )
    $classes[] = 'first';
    }
    return $classes;
    }
    add_filter( 'post_class', 'be_portfolio_post_class' );

    If there's something glaring I am missing, let me know... else I may just create a test site and play with basics (away from this theme). I convinced the client it was out of scope for now, so that problem is solved.

    Appreciate both of you taking time to help move me along. At least I've learned something (even if I didn't solve the immediate problem) I can apply ongoing.

    Paula

  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble