conditional tag for slideshow in hooks

Home Forums Support conditional tag for slideshow in hooks

Home Forums Support conditional tag for slideshow in hooks

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #190313
    Susanne

    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

    • This topic was modified 7 years, 12 months ago by Susanne.
    • This topic was modified 7 years, 12 months ago by Susanne.
    • This topic was modified 7 years, 12 months ago by Susanne.
    • This topic was modified 7 years, 12 months ago by Susanne.
    #190409
    Tom
    Lead Developer
    Lead Developer

    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.

    • This reply was modified 7 years, 12 months ago by Tom.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.