Okay
  Public Ticket #275575
Portfolio - Random Order
Closed

Comments

  • Katie started the conversation

    Is there a way for the default portfolio display be sorted randomly?

  •  8,996
    Tahir replied

    Hey Katie!

    I am afraid we dont have such an option in Salient theme. 

    Thanks


    ThemeNectar Support Team 

  • Michele replied

    Go to /wp-content/themes/salient/nectar/tinymce/shortcode-processing.php

    Find around line 1095

    $portfolio_arr = array(

    'posts_per_page' => $posts_per_page,

    'post_type' => 'portfolio',

    'project-type'=> $category,

    'paged'=> $paged

    );

    change with:

    $portfolio_arr = array(

    'posts_per_page' => $posts_per_page,

    'post_type' => 'portfolio',

    'project-type'=> $category,

    'orderby' => 'rand',

    'paged'=> $paged

    );

  •  8,996
    Tahir replied

    Hey Michele!

    Thanks for posting the hack. 

    Best,

    -T


    ThemeNectar Support Team 

  •  5
    Philipp replied

    Thanks for this hack :-)

    I was searching for a random portfolio function like this for a while now.

    Using your method, I am only having one problem:

    Some of the portfolio items are now showing up twice within one category.
    What I read so far, this has to do with the pagination I am using within my portfolio. 
    To avoid those duplicates while using pagination, I obviously need to somehow implement 
    post id's and the "post__not_in" function:

    https://wordpress.org/support/topic/order-by-rand-...

    The only problem: I got no idea how to implement his :-/

    Any chance someone could help on this?


    Thanks in advance,
    Philipp

  •  1,089
    ThemeNectar replied

    Hey Philipp, 

    I'll leave this ticket open in case Michele has a chance to respond - but for now I personally can't provide further assistance on this until it becomes a feature within the theme itself

  •  5
    Philipp replied

    Thank you for all your time and efforts! I am really appreciating it and looking forward to future releases :-)

  • Huey replied

    I wanted my Portfolio to sort alphabetically by default. I found this post and used Michele\'s tip and expanded upon it to get what I wanted.

    Again, as Michele pointed out - Go to /wp-content/themes/salient/nectar/tinymce/shortcode-processing.php - I am using Salient v 6.1.2, (which has more code them when Michele posted), so look for this fix around line 1173 and simply add this code in to the portfolio array.

    \'orderby\' => \'title\',

    \'order\' => \'ASC\',

    You are adding two extra parameters that allow to to sort on TITLE in ASCENDING order. If you wanted to sort it in DESCENDING order simply replace the ASC with DSC in my example below. Hope it helps :-)

    $portfolio_arr = array(

    \'posts_per_page\' => $posts_per_page,

    \'post_type\' => \'portfolio\',

    \'project-type\'=> $category,

    \'orderby\' => \'title\',

    \'order\' => \'ASC\',

    \'paged\'=> $paged

    );

  • oh1 replied

    So I added..
    'orderby' => 'rand',

    It worked great but I have a slight issue.  I'm using the module in two places.  For the home page instance I would like it to show the latest items.  For the portfolio page I want it random.  Is there any way to control for different sorts in different instances of the module?

    Wish there was a way to accomplish two different sorts.