• I’m trying to get my shortcode to work within my template and it has been suggested I use this code below.

    <?php echo do_shortcode(‘[shortcode option1="value1" option2="value2"]‘); ?>

    While I’m familiar with the do_shortcode(‘[shortcode]’), I am not sure I understand what to put in place for the option1=”value1″ and so on.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • You only add the option attributes if you need them. Just use your shortcode as you normally do but wrap it inside the do_shortcode function. Ignore the extra attributes if they are not relevant.

    Thread Starter get_username

    (@get_username)

    Thanks dgwyer. I tried using just <?php echo do_shortcode('[cardealer]'); ?>, but all that does is output the text [cardealer]. I contacted the owner of this plugin to see if their shortcode is supported inside the template and they wrote back with the code above that includes options and values. I’m trying to get this:

    $mydealergrid = "[cardealer]";
        $post_id = $post->ID;
        $price = c2c_get_custom('price_value');
        $year = c2c_get_custom('year_value');

    to output and thought that maybe the option 1 was $price and the value 1 was price_value. That didn’t work either.

    Your best bet is to probably get back to the Plugin author if you are in cotact with him as I don’t know what Plugin you are using etc. and would not know as much about it as the Plugin author!

    Also, be careful where you are placing your code inside the theme template files. As, if you are trying to access the $post variable to get the post ID it will only work outside the main loop if you precede the statement with:

    global $post;

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can you help define [shortcode option1="value1" option2="value2"]’ is closed to new replies.