Archived topic
conditional tag for slideshow in hooks
1 reply · Started by Susanne on April 29, 2016
Hi there Tom, still fine-tuning my portfolio site and things start coming together.
I have successfully used hooks to show a slideshow below the header (in single posts only) with this code
<?php
if ( is_single() ) : ?>
gallery shortcode
<?php endif; ?>
I have disabled showing the featured image in single posts with css. But now, if there is no image gallery, I get this error message: [RoyalSlider Error] No post attachments found.
What I want to do is to show the featured image instead of the slider, so I need some sort of statement that says: if we are on a single post and the slider gallery exists, then show it, else show the featured image. How do I write that?
Thanks in advance
I'm not sure if the gallery shortcode has an exists function, but if it does it would be something like this:
<?php if ( is_single() ) :
if ( gallery_exists() ) :
echo do_shortcode( '[ gallery shortcode ]' );
elseif ( has_post_thumbnail() ) :
the_post_thumbnail();
endif;
endif; ?>
Note: The above will not work because gallery_exists() is most likely not the function name.
