Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I add shortcode functionality to a WordPress theme that doesn't support shortcodes?

share|improve this question

migrated from stackoverflow.com Jan 7 '13 at 20:45

This question came from our site for professional and enthusiast programmers.

1  
What do you mean "doesn't support shortcodes"? That shortcodes don't work when your theme is activated, or that the theme creates no custom shortcodes for you to use? –  bungeshea Jan 7 '13 at 22:18
    
be aware that there are only two generic shortcodes: [gallery] and [caption]; what shortcodes are you trying to use? –  Michael Jan 7 '13 at 22:52

2 Answers 2

Your theme has to be removing the shortcodes.

  1. Look for remove_shortcode in the theme's files, probably functions.php.
  2. Or remove_all_shortcodes.
  3. Or it has to be removing do_shortcodes from the the_content hook. Look for remove_filter('the_content','do_shortcode',10).

If that doesn't do it, the theme is probably doing something odd with the post content-- like bypassing the normal WordPress functions. And fixing that is going to take a lot more information.

share|improve this answer
    
I've tried searching for those lines of code however I couldnt fine anything pertaining to shortcode. here's the code. –  user608518 Jan 7 '13 at 22:04
    
Where is what code? –  s_ha_dum Jan 7 '13 at 22:08
1  
Please post your code in between backticks ` –  bungeshea Jan 7 '13 at 22:35

If your theme doesn't include [shortcodes] out of the box they can be added by creating them in the functions.php file.

Here is a basic shortcode to get you started:

// add divider shortcode
function divider(){
    return '<div class="divider" style="border-top:1px solid #d1d1d1;margin:10px;">&nbsp;</div>';
}
add_shortcode('divider', 'divider');

I could have also added the divider class to my stylesheet but for purposed here I left it in the function.php file.

Then in your post/page content area all you need to do is type in [divider] and it will render the div as you have styled it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.