Shuffle Slider post (random)
-
Is it possible to implement a shuffle mode for the slider, where a random selection of post would be chosen? This way, users will see a different set of posts in the slider when the access the home page.
Admin
Sounds like a good idea.
I’ve implemented this and will be available in the next update.
Hello
Is it possible to tweak this so that the random posts displayed in the slider are taken from only one given category.
Example : I have a category named “Featured” where I store all the posts that I think most interesting for my readers. Comes a time when this category has many posts. The “random post from the “featured” category” slider would be a great way to keep these old posts alive, while keeping the rest of the blog’s contents “hidden” in the archives.
Admin
Select the category you want to be shown in the slider, then add this in your child theme’s functions.php file:
<?php
function graphene_randomise_slider_posts( $args ){
$args = array_merge( $args, array( 'orderby' => 'rand' ) );
return $args;
}
add_filter( '', 'graphene_randomise_slider_posts' );
?>Thank you for your reply.
I didnt have a child theme until now, so I created one. I only made a style.css file (with nothing in it but the minimal content you have written in your sticky post about child theme for graphen) and a function.php with nothing else but the code you just told me to add.
The child theme is working (I have to change the header image again and stuff), but the randomization of slider posts does not seem to be working: the posts are still showing from latest to oldest.
Is there anything else I should do so that the functions.php file work?
Here’s my site:
Admin
Oops..sorry, missed something in the code I provided. This one should work:
<?php
function graphene_randomise_slider_posts( $args ){
$args = array_merge( $args, array( 'orderby' => 'rand' ) );
return $args;
}
add_filter( 'graphene_slider_args', 'graphene_randomise_slider_posts' );
?>This is working like a charm. Thanks a lot, you rock!
Mod
What a cool feature! Wish I’d thought of it, but I’m glad somebody did. Thanks!
Admin
Version 1.5 will allow you to select multiple categories for the slider.
Viewing 10 posts - 1 through 10 (of 12 total)
- 1
- 2
- You must be logged in to reply to this topic.