Tuesday, June 15, 2010

Wordpress Custom Shortcodes

I have been playing with Wordpress custom shortcodes for a template we're building here at work. Unfortunately I was having some problems getting the shortcodes to be parsed. I found out the problem in the comments of the smashing magazine article below.

SHORTCODES are only parsed when using the_content() to display the page data.

This was a problem as I was pulling the page data into a variable and then echoing $page->post_content. No worries. Once I added the loop code around the page
if (have_posts()) : while (have_posts()) : the_post();
endwhile; endif;
the_content() AND my short codes worked fine!

Hurray! Wordpress can be a pain, but this was easy!


No comments:

Post a Comment