WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Have been looking at various tutorials and answers here and elsewhere and just can't get this to work. Just trying to display a simple output from a shortcode as below, but it is just outputting the actual shortcode tag to the page instead of the content from the shortcode


function welcome_roundels_func(){
    return "testing";
add_shortcode( 'welcome_roundels', 'welcome_roundels_func' );

add_action( 'init', 'register_shortcodes');



Is there anything else I have to do to enable shortcodes, or should the above work?

Edit I am also using the below code to output the content

$welcomePage = get_post( 5 ); 
echo $welcomePage -> post_content;
share|improve this question
Works for me. What is the point of add_action( 'init', 'register_shortcodes');? – s_ha_dum Feb 11 '14 at 15:03
@s_ha_dum - Looking at various websites, people suggested adding that to 'enable' the shortcodes - didn't work for me though! – wickywills Feb 11 '14 at 15:04
@s_ha_dum - Just added my output code to my question if that helps? – wickywills Feb 11 '14 at 15:09
You don't need to "enable" shortcodes. That is nonsense. They are built into the WordPress Core and have been for a long time. – s_ha_dum Feb 11 '14 at 15:10
up vote 4 down vote accepted

Your problem is here:

$welcomePage = get_post( 5 ); 
echo $welcomePage -> post_content;

Shortcodes are processed on display by via a filter on the_content which is called by the function the_content(). You've bypassed that functionality and are echoing the raw post data.

You need to output your code using a proper Loop or explicitly process the shortcode.

echo do_shortcode($welcomePage -> post_content);
share|improve this answer
Did the trick, thanks! Good explanation as well :) – wickywills Feb 11 '14 at 15:55

Your Answer


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.