Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #432538

    I have 30 blog posts in several main categories. I have placed lists of posts in the sidebars via widgets, the latest news widget with icon. The same posts always sort to the top and it would be much more interesting if I could randomize the sort. Possible? I don’t want to create a sh@t-ton of widgets.

    See:
    http://www.boulderhardwoodfloors.com/wood-basics/wood-cut/riftsawn-wood/
    and:
    http://www.boulderhardwoodfloors.com/flooring-types/reclaimed-wood-floor/

    Want to randomize the left column so it doesn’t appear the same each time you surf to a different post..

    Thanks in advance for your kind support.

    #432559

    This might be helpful. The masonry blog on this page has a setting and is set to randomize.:
    http://www.boulderhardwoodfloors.com/blog/

    #433107

    Hi!

    Try opening up /enfold/framework/php/class-framework-widgets.php and change line 452 from this.

    $additional_loop = new WP_Query("cat=".$cat."&posts_per_page=".$count);
    

    To this.

    $additional_loop = new WP_Query("cat=".$cat."&posts_per_page=".$count."&orderby=rand");
    

    Regards,
    Elliott

    #433128

    This worked perfectly for lists of posts in the sidebars via widgets, the latest news widget with icon—in the sidebar on a post page.
    Thank you.

    It does not randomize in the sidebar widget on a portfolio page. See:
    http://www.boulderhardwoodfloors.com/portfolio-item/bamboo-install-sand-and-finish/
    and:
    http://www.boulderhardwoodfloors.com/portfolio-item/american-cherry/

    Can we add a little more code to make it work on a portfolio page, in addition to working on a post page?

    Thank you in advance.

    #434199

    Hey!

    Try doing the same thing on lines 461 and 471 as well.

    Cheers!
    Elliott

    #434328

    Doesn’t seem to be working.

    Here’s what I got starting on line 450:

    			if(empty($this->avia_term))
    			{
    				$additional_loop = new WP_Query("cat=".$cat."&posts_per_page=".$count."&orderby=rand");			}
    			else
    			{
    				$catarray = explode(',', $cat);
    
    				if(empty($catarray[0]))
    				{
    					$new_query = array("posts_per_page"=>$count,"post_type"=>$this->avia_post_type);
    					$additional_loop = new WP_Query("cat=".$cat."&posts_per_page=".$count."&orderby=rand");
    				}
    				else
    				{
    					if($this->avia_new_query)
    					{
    						$new_query = $this->avia_new_query;
    					}
    					else
    						$additional_loop = new WP_Query("cat=".$cat."&posts_per_page=".$count."&orderby=rand");
    					{
    						$new_query = array(	"posts_per_page"=>$count, 'tax_query' => array(
    														array( 'taxonomy' => $this->avia_term,
    															   'field' => 'id',
    															   'terms' => explode(',', $cat),
    															   'operator' => 'IN')
    															  )
    														);
    					}
    				}
    
    				$additional_loop = new WP_Query($new_query);
    			}

    Could you please take another gander to see if I am putting in the code correctly?

    #435377

    Hey!

    It should look like this.

    if(empty($this->avia_term))
    {
    	$additional_loop = new WP_Query("cat=".$cat."&posts_per_page=".$count."&orderby=rand");
    }
    else
    {
    	$catarray = explode(',', $cat);
    
    	if(empty($catarray[0]))
    	{
    		$new_query = array("posts_per_page"=>$count,"post_type"=>$this->avia_post_type, "orderby"=>"rand");
    	}
    	else
    	{
    		if($this->avia_new_query)
    		{
    			$new_query = $this->avia_new_query;
    		}
    		else
    		{
    			$new_query = array(	"orderby"=>"rand","posts_per_page"=>$count, 'tax_query' => array(
    											array( 'taxonomy' => $this->avia_term,
    												   'field' => 'id',
    												   'terms' => explode(',', $cat),
    												   'operator' => 'IN')
    												  )
    											);
    		}
    	}
    
    	$additional_loop = new WP_Query($new_query);
    }
    

    Regards,
    Elliott

    #435464
    This reply has been marked as private.
    #435801

    Hi!

    Great, glad we could help :)

    Regards,
    Rikard

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.