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.

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?

share|improve this question
add comment

2 Answers

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' );
share|improve this answer
add comment

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.

share|improve this answer
    
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 –  Vittorio Vittori Oct 18 '11 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. –  Jonathan Liuti Oct 18 '11 at 15:43
    
Could you try to disable every plugins and go back to default twentyteleven theme and see if it's fixed ? –  Jonathan Liuti Oct 19 '11 at 14:36
    
Yes, If I simply use the default twentyteleven it works, but not in my theme –  Vittorio Vittori Oct 19 '11 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 ? –  Jonathan Liuti Oct 19 '11 at 15:01
add comment

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.