Support » Fixing WordPress » Using shortcodes within a template

  • Ok, here’s the issue. Originally I created a page and manually listed each of my movies like so:

    <li> <!--imdb-->ร†on Flux (2005)<!--/imdb--></li>
    <li> <!--imdb-->"The Storyteller" (1988)<!--/imdb--></li>
    <li> <!--imdb-->10,000 BC (2008)<!--/imdb--></li>

    The imdb shortcodes above create links for the respective movie, gathering it’s imdb info.

    Now, I’ve added a table to my database and inserted all my movies into it. Than I created a template for which I go through the table and list all the movies. So far, so good. However, I want to still create the imdb links above for them. However, adding ‘<!–imdb–>’ and ‘<!–/imdb–> into the template code itself, seems to produce no results.

    Here’s an example within my loop:
    <td><!--imdb--><?php echo $mymovie->name;?><!--/imdb--></td>

    I tried messing around with something like so:
    echo do_shortcode('<!--imdb-->');

    but wasn’t sure how to write it, opening/closing and where movie would go?

    Working page:
    Non-working template:

    Any suggestions folks?


Viewing 10 replies - 1 through 10 (of 10 total)
  • I also tried the following, with no results either:

    <td><?php echo "<!--imdb-->".$mymovie->name."<!--/imdb-->";?></td>
    <td><?php echo do_shortcode('<!--imdb-->').$mymovie->name.do_shortcode('<!--/imdb-->');?></td>

    do_shortcode( $mymovie->name );

    Do shortcode instructs WordPress to run the shortcode conversion on the given data…

    So in this case, your data is in $mymovie->name, so you place that into the call.. (as per the code i’ve posted above).

    Assuming your IMDB shortcode is registered with WordPress, that should be all you need… (unless you have some custom written function to do the conversion?).



    If you are writing your list directly to your template, shortcodes won’t work. Parsing shortcodes is part of getting “the_content()” ready, and your lists aren’t contained in a WP post.

    You’re going to have to duplicate within your template the functions that parse the imdb shortcodes, or call the imdb functions directly.

    Yes sorry, my mistake, as Steve said, the function is reserved for usage explicitly on the content.

    Shouldn’t be hard to write a basic function if you know what to expect in the data you’re passing into it.

    @ t31os_ : but that data is just a string, so without referencing the imdb shortcode, how would

    do_shortcode( $mymovie->name );

    know which shortcode functionality to perform on that text?

    @ stevejohnson : I was afraid of that. I did try one function call, but I’m sure I didn’t have entire path and what not. So no short answer, if I want this to work via templates I’ll have to familiarize myself with all the imdb plugin files and determine what needs to be brought into the template itself?

    Well thanks anyway guys. If I get it figured out, I’ll post it here.


    So now I tried the following:

    <td><?php echo imdb_external_call($mymovie->name);?></td>

    and got this:

    Fatal error: Call to a member function imdbid() on a non-object in /home/gbuffett/public_html/wp-content/plugins/imdb-link-transformer/inc/ on line 52

    I’ll keep toying with it. ๐Ÿ™

    Did you see the response from the author here.

    There is no response from the author on this page, and this does in fact cause problems. worked fine for months, then updated to the latest version and problems. Same issue here

    Sorry, I didn’t update my status. I stopped looking for a solution as I found dvd profiler and phpmyprofiler and created an online dvd library which I linked from my wordpress. I need to purchase the registration code to upload more than 50 dvds. But I really like the look and feel of it so far.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Using shortcodes within a template’ is closed to new replies.