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

  • 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? – shea 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

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.

  • 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 ` – shea Jan 7 '13 at 22:35

Theme I had did things like (don't know what's the problem here yet):

<?php $page_content = get_post(); ?>
  <?php echo $page_content->post_title;?>
  <?php echo $page_content->post_content;?>

echo the_content() didn't do anything. I had to replace a line with

<?php echo do_shortcode($page_content->post_content);?>



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.


I had the same problem, for some reason I had shortcodes in my posts and pages, but not in my custom page that i created.

For some reason, I added this in the beginning of my file and it solved the problem:

/* Template Name: page without author details */
/* Template Post Type: page */

(Yep, a comment in the beginning of the custom page )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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