WordPress.org

Ready to get started?Download WordPress

Forums

Meteor Slides
[resolved] Random Slides from a Category (6 posts)

  1. fox3586
    Member
    Posted 1 year ago #

    I am looking to add 5 or so random slides from a category to be pulled for a slideshow. I have them already showing in random order, but I would like to have about 30 or so and have the slideshow grab a few at random.

    Has anyone tried this?

    (Also, love the plugin!)

    http://wordpress.org/extend/plugins/meteor-slides/

  2. Josh Leuze
    Member
    Plugin Author

    Posted 1 year ago #

    Hi, thanks for trying my plugin! I'm not sure I follow you exactly. So you have a slideshow with slide posts in it that is working, and you want to add blog posts to it from a certain category, is that right?

    You can use a custom slideshow template, and change the query for the slide loop to include slide and blog posts. But the category/slideshow taxonomies for that are going to be an issue.

    If you specify a category or slideshow, it will only get slide or blog posts in that category or slideshow, so you would need to have a taxonomy that was added to both the slide and blog post types. You can either extend categories or slideshows to cover both types, or create a new taxonomy that is added to both.

  3. fox3586
    Member
    Posted 1 year ago #

    Let me try to explain again. Since I use the same slideshow on every page, I am looking to randomize how it looks each time a page is loaded.

    My slideshow (hammondacademy.org) shows the images I have select in random order. That works great. What I would like is to have a pool of images that the slideshow would use only a few of at a time chosen randomly. So 30ish images are available, but each time the page is drawn, the slideshow just grabs 5 out of those 30 at random.

    I hope I was more clear this time.

  4. Josh Leuze
    Member
    Plugin Author

    Posted 1 year ago #

    Ah, that makes sense! There are two kinds of random when it comes to setting up the slideshow. The random that you are using right now via metadata is part of the slideshow script and randomizes only the latest slides that are being loaded, 5 or however many you set in the quantity.

    The other type of random you can use is in the WordPress post query, this will draw on all the slide posts, the 30ish you mention, and load 5 or however many you set at random.

    You can use this second type of random by using a custom slideshow template. Just update the WP_Query function and add an "orderby" parameter:

    $meteor_loop     = new WP_Query( array(
    
    		'post_type'      => 'slide',
    		'orderby'        => 'rand',
    		'slideshow'      => $slideshow,
    		'posts_per_page' => $meteor_options['slideshow_quantity']
    
    	) );
  5. fox3586
    Member
    Posted 1 year ago #

    Perfect! Thanks so much. Now I just need to start adding more pictures.

  6. Josh Leuze
    Member
    Plugin Author

    Posted 1 year ago #

    You're welcome!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic