• I’m trying to do an if home or if front page statement in my header.php file and I’m getting an error since I have a piece of shortcode inside of it to get a slider widget inside of it. So this code won’t work:

    <?php if ( is_front_page() && is_home() ) {
    echo ('<div id="moneyshot"><?php echo do_shortcode( '[responsive_slider]' ); ?></div>');
    } ?>

    Any idea how to get the do_shortcode to work?

Viewing 3 replies - 1 through 3 (of 3 total)
  • It should be:

    if ( is_front_page() || is_home() )

    Uisng && in there means that both conditions need to be true, and that’s pretty much never going to happen. Using || means that only one of the conditions needs to be true.

    you are using a php tag within a string started with the first echo;

    clear the syntax errors;

    for example:

    <?php if ( is_front_page() && is_home() ) {
    echo '<div id="moneyshot">' . do_shortcode( '[responsive_slider]' ) . '</div>';
    } ?>

    also, consider the suggestion by @catacaustic.

    Thread Starter databell96

    (@databell96)

    Thanks, it’s working now.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Doing an if statement with a do_shortcode nested in it’ is closed to new replies.