Title: Using shortcodes within a template
Last modified: August 19, 2016

---

# Using shortcodes within a template

 *  [jeffwithag](https://wordpress.org/support/users/jeffwithag/)
 * (@jeffwithag)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/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: [http://jeffwithag.com/misc/my-movies/](http://jeffwithag.com/misc/my-movies/)
   
   Non-working template: [http://jeffwithag.com/misc/movie-library/](http://jeffwithag.com/misc/movie-library/)
 * Any suggestions folks?
 * Thanks,
    Geoff

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Thread Starter [jeffwithag](https://wordpress.org/support/users/jeffwithag/)
 * (@jeffwithag)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/using-shortcodes-within-a-template/#post-1307874)
 * 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>`
 *  Thread Starter [jeffwithag](https://wordpress.org/support/users/jeffwithag/)
 * (@jeffwithag)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/using-shortcodes-within-a-template/#post-1308098)
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/using-shortcodes-within-a-template/#post-1308105)
 *     ```
       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?).
 *  [Steve](https://wordpress.org/support/users/stevejohnson/)
 * (@stevejohnson)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/using-shortcodes-within-a-template/#post-1308120)
 * 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.
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/using-shortcodes-within-a-template/#post-1308125)
 * 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.
 *  Thread Starter [jeffwithag](https://wordpress.org/support/users/jeffwithag/)
 * (@jeffwithag)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/using-shortcodes-within-a-template/#post-1308126)
 * @ 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.
 * Thanks,
    Geoff
 *  Thread Starter [jeffwithag](https://wordpress.org/support/users/jeffwithag/)
 * (@jeffwithag)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/using-shortcodes-within-a-template/#post-1308148)
 * 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/imdb-movie.inc.php
   > on line 52
 * I’ll keep toying with it. 🙁
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/using-shortcodes-within-a-template/#post-1308223)
 * Did you see the response from the author here.
    _ikiru.ch/blog/imdb-link-transformer-
   wordpress-plugin/comment-page-7#comment-166700_
 *  [twhiting9275](https://wordpress.org/support/users/twhiting9275/)
 * (@twhiting9275)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/using-shortcodes-within-a-template/#post-1308240)
 * 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
 *  Thread Starter [jeffwithag](https://wordpress.org/support/users/jeffwithag/)
 * (@jeffwithag)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/using-shortcodes-within-a-template/#post-1308242)
 * 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.
 * [http://www.jeffwithag.com/mydvds/](http://www.jeffwithag.com/mydvds/)

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Using shortcodes within a template’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 10 replies
 * 4 participants
 * Last reply from: [jeffwithag](https://wordpress.org/support/users/jeffwithag/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/using-shortcodes-within-a-template/#post-1308242)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
