Possible to use conditional shortcodes in templates?

Discussion in 'Templates customization' started by patmac, Jul 13, 2012.

  1. patmac

    patmac New Member

    Joined:
    Jan 23, 2012
    Messages:
    26
    I'm trying to do something like:
    <? echo do_shortcode('[am4guest]'); ?>
    <a href="<? bloginfo('url'); ?>/members/login">Login</a>
    <? echo do_shortcode('[/am4guest]'); ?>

    ..in my header.php file, but the ending shortcode just returns /am4guest instead of actually closing the conditional.

    Anyone have any solutions for running conditional shortcodes like this in templates?
  2. patmac

    patmac New Member

    Joined:
    Jan 23, 2012
    Messages:
    26
    I figured out that you can concatenate shortcodes like so:
    <? echo do_shortcode(
    '[am4guest]' .
    '<li class="first"><a href="' . get_bloginfo('url') . '/members/login">Login</a></li>
    <li><a href="' . get_bloginfo('url') . '/signup">Become a Member</a></li>' .
    '[/am4guest]');
    ?>
  3. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Nice hack!

    Thanks for sharing.

    David

Share This Page