Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable shortcodes in a wordpress theme

I develop a new theme for wordpress 3.3.1 from scratch and shortcodes are not working on it. As I searched until now it is a matter of filtering the content containing the shortcode, filter code added in a theme specific location(shorcodes are working with another theme). So, my question is : What is the code for a general shortcode theme enable ?

like image 517
Nistor Teodora Avatar asked Mar 22 '12 10:03

Nistor Teodora


1 Answers

To execute a single shortcode, run it with

echo do_shortcode('[your_short_code]');

If the shortcode(s) are in the post content, make sure you're displaying it with

<?php the_content();?>

Or

<?php echo apply_filters('the_content',$post_content);?>

Or

<?php echo apply_filters('the_content',$wp_query->post->post_content);?>

The important thing is: if you aren't using the function "the_content()" you need this line <?php echo apply_filters('the_content',$wp_query->post->post_content);?> where in the second argument you have to put the variable of the post content you want to show.

like image 134
alesub Avatar answered Oct 19 '22 15:10

alesub