Grow your CSS skills. Land your dream job.

shortcode isn’t working

  • # January 10, 2013 at 10:05 pm

    In WordPress. Got this shortcode in my functions.php

    function amaranthe_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 = ‘‘ .$content. ‘‘;

    return $out;
    }
    add_shortcode(‘buy-tickets’, ‘amaranthe_buy_tickets’);

    in my template file where I want the shortcode to display, I have this

    < ?php echo do_shortcode("[buy-tickets]"); ?>

    and in the post, I have this

    [buy-tickets]Tickets[/buy-tickets]

    in the output, all I get is this

    for some reason, the content is missing.

    # January 10, 2013 at 11:33 pm

    Shouldn’t your actual shortcode in the post be…

    [buy-tickets link="http://whateverlink.com"]Tickets[/buy-tickets]

    You are seeing the “#” because it is the default in the PHP

    # January 10, 2013 at 11:39 pm

    The link shows fine. It’s the “Tickets” that isn’t showing up. The content is missing

    # January 11, 2013 at 12:51 am

    I just tested it, it is working for me. Are you by chance using this in a widget area? If so, you have to turn that on.

    add_filter(‘widget_text’, ‘do_shortcode’);

    Otherwise, I am stumped. :/

    # January 11, 2013 at 12:54 am

    Just to show you since I have it setup, it can be viewed [here](http://demo.scottnix.com/shortcode/shortcode-buttons/ “here”)

    Obviously no styling… but hmm, has to be something else. :/

    # January 12, 2013 at 2:42 am

    I don’t know what the issue is either. The only thing I can think of it that it has something to do with how I am getting the posts

    # January 25, 2013 at 7:42 am

    @cybershot did you checked your apache config file ? there is an option to enble shortcode

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".