WordPress.org

Ready to get started?Download WordPress

Forums

Meteor Slides
[resolved] Conditional statement (5 posts)

  1. simonbugler
    Member
    Posted 3 years ago #

    Is it possible to create a conditional statement that will display a default slideshow if none is selected.

    Currently I'm auto filling the category slug like so:

    <?php
    			if (is_category( )) {
    			$cat = get_query_var('cat');
    			$yourcat = get_category ($cat);
    			}
    			?>
    
    			<?php if(function_exists('meteor_slideshow')) { meteor_slideshow(".$yourcat->slug .", ""); } ?>

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

  2. Josh Leuze
    Member
    Plugin Author

    Posted 3 years ago #

    Hi Simon, this should be doable but I'm not sure I understand exactly how you have this setup.

    So you are using this code on your blog category pages and loading the blog category as the slideshow option so that you can load a slideshow that has been setup for that category?

    But categories and slideshows are both taxonomies, so you couldn't use the same names in each and match them up, is there something I'm missing here?

  3. simonbugler
    Member
    Posted 3 years ago #

    So you are using this code on your blog category pages and loading the blog category as the slideshow option so that you can load a slideshow that has been setup for that category?

    This is exactly what I'm doing - and it works very well!!??

    The only problem is if a slideshow doesn't exist. Currently I have a background image that shows - but wondered what the code would be to select a default slideshow for when one doesn't exist

  4. simonbugler
    Member
    Posted 3 years ago #

    Ok - this only works if I use the add category field on the post/slide page..!

    Is this a bug in WordPress - am I going to have problems for having duplicate category/slug names??

    Is there a better way to insert slide shows on category pages?

  5. Josh Leuze
    Member
    Plugin Author

    Posted 3 years ago #

    It's not a bug per se. The categories, tags, and custom taxonomies like slideshows are all considered "terms" by WordPress. Each term has to have a unique slug, like if you create category called Test and then a tag called Test, the category will have the slug "test" and the tag will have the slug "test-2".

    So right now you have one template file, category.php, that you have this conditional statement in to dynamically load the correct slideshow?

    I don't know how many categories/slideshows you have, but you could create some custom category templates and add the corresponding slideshow to each template. Then you could add a default slideshow to the category.php file for categories that don't have a slideshow.

    If you have a ton of categories and need this to be more dynamic, I'd design your statement to work with a certain naming structure. Like if you have a News category, create a slideshow called "News Slideshow". And in the statement, have it get the category slug and append "slideshow" to it.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic