Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #386531

    Hi there
    I’m using the post slider to pull in testimonials. I was wondering if there is a way to pull in posts randomly?

    #386980

    Hi reddishpinkmedia!

    Thank you for coming back.

    There is a filter hook, where you can manipulate the query parameters.

    In functions.php use code like:

    
     add_filter('avia_post_slide_query', 'my_avia_post_slide_query', 10, 2);
     
     function my_avia_post_slide_query($query, $params)
     {
    	 
    	 $query['orderby'] = 'rand';
    	 
    	 return $query;
     }
    

    More info about $param you find at: enfold\config-templatebuilder\avia-shortcodes\postslider.php line 452 – 510.

    Cheers!
    Günter

    #386987

    Great! But this will change all the sliders. Can you isolate one post slider, on one page?

    #387622

    Hey!

    Thank you for coming back.

    There is only a workaround:

    In functions.php at the bottom activate custom css for the ALB:

    
    /*
     * add option to edit elements via css class
     */
     add_theme_support('avia_template_builder_custom_css');
    

    This adds a field Custom Css Class at the bottom of the post slider popup.
    Enter there a name to the slider(s) you want to change, e.g. my_random_sliders

    Replace the code above with the following:

    
    add_filter('avia_post_slide_query', 'my_avia_post_slide_query', 10, 2);
     
     function my_avia_post_slide_query($query, $params)
     {
    	 $needle = 'my_random_sliders';
    	 if( isset($params['class']) && ( stripos( $params['class'], $needle ) !== false) )
    	 {
    		$query['orderby'] = 'rand';
    	 }
    	 
    	 return $query;
     }
    

    Cheers!
    Günter

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