Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #121215

    Right Angle S
    Participant

    Hi,

    Is there a way to choose the order of how portfolio items are displayed on a portfolio archive page?

    Many thanks for your help.

    #121560

    Kosher K
    Member

    Hi There,

    Thanks for writing in,

    Can you try adding this code below and see how it works

    function cmk_custom_order( $wp_query ) {
         /* Get the post type from the query*/
        $post_type = $wp_query->query['post_type'];
        /*If Post type is Portfolio*/
        if ( $post_type == 'x-portfolio') {
        /* Set Order to Random*/
    	$wp_query->set('orderby', 'rand');
        /* un-comment if not using random order */
        //$wp_query->set('order', 'DESC');
        }
    }
    /* Change Order settings before displaying the Postype*/
    add_filter('pre_get_posts', 'cmk_custom_order');

    I set the order to random so you’ll see right away if the code is working, just reload the page few times and if its working, the very first post should change every refresh

    For the list of all order option please check WP Query order paramater http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

    #122874

    Right Angle S
    Participant

    That’s worked perfectly, thank you very much.

    Hers is a link to the page in question:
    http://rightanglecreative.co.uk/portfolio/

    I have looked at the link you provided regarding the various ways of ordering and the following two were of particular interest:

    1 – ‘meta_value’ – Note that a ‘meta_key=keyname’ must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect). Use ‘meta_value_num’ instead for numeric values.
    2 – ‘meta_value_num’ – Order by numeric meta value (available with Version 2.8). Also note that a ‘meta_key=keyname’ must also be present in the query. This value allows for numerical sorting as noted above in ‘meta_value’.

    If I wanted to order the portfolio items by a custom order to be visually best, would I assign one of the above to each post and then order as I wish? For example, 1 will be visual merchandising manual, 2 will be water bottles and so on…

    If this is the case, how do I assign these orders to each post?

    Thank you very much for your time and help.

    #123146

    Cousett
    Member

    There has to be a custom field that you are ordering by. You will have to add a custom post field to your portfolio items. You can do this by adding the information to the custom Fields box:

    #139160

    tdash
    Participant

    Hi I read through this string, and am still unsure how I would re-order my portfolio index page. I would like to have control over which items go first, second, etc. (not random)

    What are the steps to be able to do this without rebuilding all the portfolio pages from scratch?

    #139330

    Christian
    Moderator

    Hey there,

    There’s no option for that currently so template modification is necessary. But, we have listed this in our feature request list and might include additional Portfolio sorting options in a future release.

    Thanks.

    #139690

    tdash
    Participant

    That would be a super important option. Most use cases for ordering the display of thumbnails in portfolio index are not based on recency, but rather on how the thumbnails display in relation to one another. A lot of trial and error is necessary to come up with the final order. Thanks for considering this.

    #139839

    Kosher K
    Member

    No Problem,

    Have a great day

    #666209

    WPH2o
    Participant

    Useful (and somewhat obvious–for Portfolios) to have an order feature.

    #666322

    Rue Nel
    Moderator

    Hello There,

    Thanks for updating this thread!
    We’re just glad that it has been useful to you.

    If you have any additional questions at this time we kindly ask that you open them up in a separate thread. The longer threads get in the forum, they become more difficult to support as they tend to drift off topic and they also make it troublesome for users trying to search for solutions. Keeping threads relevant to their original inquiry ensures that we can keep better track of what has been resolved and that users can more effectively find answers to similar issues they might be experiencing.

    Thanks!

    #709458

    Right Angle S
    Participant

    Hi there,

    Here are two example pages that we are working on and have found to contain errors:
    http://lathamshome.com/furniture/dining/dining-tables
    http://lathamshome.com/furniture/dining/dining-chairs

    We have used custom development within our Child Theme’s functions.php file (as advised above) to order the portfolio items alphabetically within these portfolio archive pages. BUT, even though most portfolio have successfully been ordered alphabetically, there are still a few that are not. For example, the “Hadstock Table” would appear before the “Harrogate Table – Extending”, “Harrogate Table – Large” and “Harrogate Table – Small” but it does not appear that way.

    Could you please advise as to how we can fix this?

    Here is the complete functions.php from our Child Theme:

    <?php
    
    // =============================================================================
    // FUNCTIONS.PHP
    // -----------------------------------------------------------------------------
    // Overwrite or add your own custom functions to X in this file.
    // =============================================================================
    
    add_filter( 'post_type_link', 'x_remap_portfolio_permalink_to_project_link', 10, 4);
    
    function x_remap_portfolio_permalink_to_project_link($post_link, $post, $leavename, $sample) {
    
        if ('x-portfolio' == $post->post_type) {
            $custom = get_post_custom($post->id);
    
            if (isset($custom['_x_portfolio_project_link']) && $custom['_x_portfolio_project_link'][0]!='')
                return $custom['_x_portfolio_project_link'][0];
        }
    
        return $post_link;
    }
    function cmk_custom_order( $wp_query ) {
         /* Get the post type from the query*/
        $post_type = $wp_query->query['post_type'];
        /*If Post type is Portfolio*/
        if ( $post_type == 'x-portfolio') {
        /* Set Order to Random*/
    	$wp_query->set('orderby', 'name');
        /* un-comment if not using random order */
        //$wp_query->set('order', 'ASC');
    	$wp_query->set('order', 'ASC');
        }
    }
    /* Change Order settings before displaying the Postype*/
    add_filter('pre_get_posts', 'cmk_custom_order');

    Thank you in advance for your help with this matter.

    #709811

    Lely
    Moderator

    Hello There,

    Thanks for posting in. Upon checking your page, the ordering is correct.

    Hadstock Table
    Harrogate Table – Extending
    Harrogate Table – Large
    Harrogate Table – Small
    Hastingwood Table
    Havering Table

    Please purge/delete cache if you have caching plugin or you may disable it first.

    Always,
    X

    #913307

    ramisahar
    Participant

    Is there any new way of ordering portfolio items? I noticed the last time you wrote it would be added into themeco was quite some time ago… any updates since then?

    #913708

    Rue Nel
    Moderator

    Hello There,

    Regretfully there is no updates on this thread!
    The above solution should work out for you. Please try it out.