0

I had this custom shortcode working but it seems to have stopped. I had the code running through another shortcode that ran the loop for category posts. I have since improved the code so that it works great in it's own custom template. But now for some reason that I can't figure out, the shortcode don't work anymore.

function ritualHealing_buy_tickets( $atts, $content = null ) {
    extract(shortcode_atts(array(
        'link'  => '#',
        'target'    => '',
        'variation' => '',
        'size'  => '',
        'align' => '',
    ), $atts));

    $style = ($variation) ? ' '.$variation. '_gradient' : '';
    $align = ($align) ? ' align'.$align : '';
    $size = ($size == 'large') ? ' large_button' : '';
    $target = ($target == 'blank') ? ' target="_blank"' : '';

    $out = '<a' .$target. ' class="tickets_btn' .$style.$size.$align. '" href="' .$link. '">' .do_shortcode($content). '</a>';

    return do_shortcode( $out );
 }
 add_shortcode('buy_tickets', 'ritualHealing_buy_tickets');

The shorcode is getting called from the excerpt box like so:

[buy_tickets link="#"]Tickets[/buy_tickets]

And on the page, what I am getting is this:

[buy_tickets link="#"]buy tickets[/buy_tickets]

I am calling my content from the excerpt from the loop in my custom template with the the_excerpt() function.

I can't figure out why my page won't render the shortcode anymore. I have tried many different things over the last few days that I have read from this site and others including a custom excerpt function. That didn't work either.

2

Okay, I finally found it the answer. You need to add two filters to your functions.php file in order to run shortcodes through it.

 add_filter( 'the_excerpt', 'shortcode_unautop');
 add_filter( 'the_excerpt', 'do_shortcode');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.