Viewing 21 posts - 1 through 21 (of 21 total)
  • Author
    Posts
  • #16796

    Hey Guys,

    this is a great theme!

    However, I have a question:

    How can I showcase random portfolio elements in a widget? The lastest widget is ordered by date and I didn’t find how to change in to random.

    Thanks

    Andi

    #92877

    In eunoiaframeworkphpclass-framework-widgets.php replace:

    $this->avia_new_query = ''; //set a custom query here

    with

    $this->avia_new_query =  array(	"posts_per_page"=>$count, orderby => 'rand', 'tax_query' => array(
    array( 'taxonomy' => $this->avia_term,
    'field' => 'id',
    'terms' => explode(',', $cat),
    'operator' => 'IN')
    )
    );

    #92878

    Hey Dude,

    thank you very much, but unfortunately this leads to an empty widget.

    Any ideas?

    Regards

    Andi

    #92879

    Hi,

    Try this instead.

    $this->avia_new_query =  array(	'orderby' => 'rand', 'tax_query' => array(
    array( 'taxonomy' => $this->avia_term,
    'field' => 'id',
    'terms' => explode(',', $cat),
    'operator' => 'IN')
    )
    );

    Regards,

    Ismael

    #92880

    I am sorry, but there’s still only an empty widget. That didn’t work as well.

    Regards

    Andi

    #92881

    Hi,

    Remove all of the changes you’ve done and find this code instead

    $new_query = array("posts_per_page"=>$count,"post_type"=>$this->avia_post_type);

    Replace it with this

    $new_query = array("posts_per_page"=>$count,"post_type"=>$this->avia_post_type,"orderby"=>"rand");

    Regards,

    Ismael

    #92882

    OK, now I can see the elements again, but they are still in the same order. I turned off the cache.

    Regards

    Andi

    #92883

    Hi Andi,

    The “orderby”=>”rand” should have done the trick but I’m not sure why it didn’t work on your end. Let me tag the rest of the support to see the issue.

    Regards,

    Ismael

    #92884

    Hi,

    Could you try this please:

    $this->avia_new_query = array(	'orderby' 	=> 'rand',
    'posts_per_page' =>-1,
    'tax_query' => array( array( 'taxonomy' => $this->avia_term,
    'field' => 'id',
    'terms' => explode(',', $cat),
    'operator' => 'IN')));
    //-1 change for $count

    Any difference in number of portfolio items shown?

    Thanks,

    Nick

    #92885

    Hi Nick,

    thank you for your effort.

    The number of shown items has changed to zero, unfortunately.

    I hope you do have another idea to solve this.

    Best regards

    Andi

    #92886

    Hi,

    Never fear, we almost have it right where we want it. Please try this:

    $this->avia_new_query=array(
    'orderby' => 'rand',
    'posts_per_page' => -1,
    'post_type' => $this->avia_post_type,
    'tax_query' => array(
    array( 'taxonomy' => $this->avia_term,
    'field' => 'id',
    'terms' => explode(',', $cat),
    'operator' => 'IN'
    )
    )
    );

    Thanks,

    Nick

    #92887

    Guys, I am feeling very sorry, but I still can’t see anything ;-)

    I am replacing

    $this->avia_new_query = ”; //set a custom query here

    in the Avia Portfoliobox section. Is that correct?

    Regards

    Andi

    #92888

    Hi.

    This code is included on AVIA NEWSBOX section, find this code

    $new_query = array("posts_per_page"=>$count,"post_type"=>$this->avia_post_type);

    Then replace it with this.

    $new_query = array("posts_per_page"=>$count,"post_type"=>$this->avia_post_type,"orderby"=>"rand");

    Remove browser cache then reload the page 3-5 times and see if it works. It works in my end.

    Regards,

    Ismael

    #92889

    I hate to say, but there is still no random display.

    How can we figure this out?

    #92890

    Hi,

    Please try to remove browser history and cache. I have no more idea what to do. Let me tag the rest of the support team.

    Regards,

    Ismael

    #92891

    Hi,

    Tried and tested. Please follow the steps in Dude’s original reply regarding where to paste the code below:

    $this->avia_new_query  = (array('showposts' => 1, 'orderby'=> 'rand', 'post_type' => array('portfolio')));

    Please keep refreshing page, even if five in a row appear the same. Sometimes randomness can look quite static.

    I even made a commemorative video to document this achievement – https://docs.google.com/open?id=0B8hqGBMSfHtKdk4xbmlXdXYyRDg – (for some reason nothing was working for the longest time).

    Thanks,

    Nick

    #92892

    Thank you very much! This seems to work, I can see random entries now.

    However, there are some issues remaining:

    My aim is to show two widgets: 1 showing 2 posts from category A, and 1 showing 4 posts from category B.

    - Only one entry per widget is shown.

    - Both widgets are showing both categories.

    - Even private entrys are shown.

    Besides this, it’s working great!

    I hope we can solve these minor issues finally.

    Thank you

    Andi

    #92893

    Try following code instead:

    $this->avia_new_query  =
    array('showposts' => $count,
    'orderby'=> 'rand',
    'tax_query' => array(
    array( 'taxonomy' => $this->avia_term,
    'field' => 'id',
    'terms' => explode(',', $cat),
    'operator' => 'IN'
    )
    ),
    'post_type' => array('portfolio')
    );

    Now you’re able to use the widget settings to adjust the number of posts, categories, etc.

    #92894

    With this code I am getting the empty widget again.

    I am really sorry that I am keeping you that busy – thank you very much for your effort.

    Best regards

    Andi

    #92895

    I think I found the issue – it’s framework/widget class related and I’ll ask Kriesi to look into it. For now you can try following – replace following code in eunoiaframeworkphpclass-framework-widgets.php

    $new_query = array(	"posts_per_page"=>$count, 'tax_query' => array(
    array( 'taxonomy' => $this->avia_term,
    'field' => 'id',
    'terms' => explode(',', $cat),
    'operator' => 'IN')
    )
    );

    with:

    $orderby = ($this->avia_term == 'portfolio_entries') ? 'rand' : 'date';
    $new_query = array( "posts_per_page"=>$count, 'orderby' => $orderby, 'tax_query' => array(
    array( 'taxonomy' => $this->avia_term,
    'field' => 'id',
    'terms' => explode(',', $cat),
    'operator' => 'IN')
    )
    );

    Don’t forget to revert the change(s) we provided in the last posts.

    #92896

    Perfect!

    You guys rock!

    Thank you very much,

    Andi

Viewing 21 posts - 1 through 21 (of 21 total)

The topic ‘Latest Portfolio Widget: Random order’ is closed to new replies.