I have WordPress 3.2.1 and I have created a personal shortcode, everything works fine until I change the Permalink Settings from Default to Custom Structure. The shortcodes stop to work permanently, instead I turn back to Default setting.

Hello, I'm [birthday year="1975-03-25"] years old.

I've added add_shortcode function in my theme's functions.php.
If I add the new shortcode to the original WordPress theme Twenty Eleven in the functions.php file, it works fine!

my functions.php file:

function short_birthday ($date) {
    list($Y,$m,$d) = explode("-", $date['year']);
    return( date("md") < $m.$d ? date("Y")-$Y-1 : date("Y")-$Y );
add_shortcode('birthday', 'short_birthday');

this is the only thing I've added to functions.php.

How my theme can block the shortcodes? It's the only thing I've did.
Can I do something to fix it?

3 Answers 3


This is how your shortcode should be set up:

function short_birthday( $atts, $content = NULL ) {
    extract( shortcode_atts( array(
        'year' => 'default value'
    ), $atts ) );

    list( $Y, $m, $d ) = explode( "-", $year );
    $data = date( "md" ) < $m.$d ? date( "Y" )-$Y-1 : date( "Y" )-$Y;
    return $data;
add_shortcode( 'birthday', 'short_birthday' );

Have you tried to use the html view to paste the shortcode ? Sometimes html tags are copied when you copy the shortcode and makes it behave like this.

  • the only way to crunch the shortcode is to set in my page.php the function echo do_shortcode( '[contact-form-7 id="12" title="Contact form 1"]' ); it's the first time I get this kind of error
    – vitto
    Oct 18, 2011 at 15:25
  • very strange indeed. I'm using it on more than 20 sites without an issue... I got the problem only once by copying the shortcode example on their website and it ended up like this: <code>[contact-form-7 id="1234" title="Contact form 1"]</code> and the <code> tag broke the shortcode rendering... That's all i can think off. Oct 18, 2011 at 15:43
  • Could you try to disable every plugins and go back to default twentyteleven theme and see if it's fixed ? Oct 19, 2011 at 14:36
  • Yes, If I simply use the default twentyteleven it works, but not in my theme
    – vitto
    Oct 19, 2011 at 14:54
  • Then there must be something in your theme that disable the rendering of shortcodes. If you remove your custom shortcode, are other shortcode still working ? Oct 19, 2011 at 15:01

The truth is that with a platform like WordPress it is very hard to pin point the problem as there can be hundreds of causes and with the ever growing template and plugins...anyways I had a case where it took me a long time to figure out so I want to share quickly here.

Check to see how your template files display the content of posts/pages. If the code used is simply the the_content(); then that is correct. In my case I had edited the template myself and this is something many plugins do for example to insert ads or etc.

I was getting the content using get_the_content(); which does not apply the short codes, also check for any apply_filters that can disable short codes.

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.