WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

I'm trying to remove the shortcodes from a child theme. In my functions.php file (for the child theme), I've put:

function my_remove_shortcode(){
    return '';
}
add_shortcode('entry-twitter-link', 'my_remove_shortcode');

Where entry-twitter-link is a shortcode created in the parent. However, the entry still shows up on my posts. Ideas on what's wrong?

share|improve this question
up vote 9 down vote accepted

Try this out. Remove the already added shortcode then add the new shortcode on the init hook.

function shortcode_cleaner() {
    remove_shortcode( 'entry-twitter-link' ); // Not exactly required
    add_shortcode( 'entry-twitter-link', 'my_remove_shortcode' );
}
add_action( 'init', 'shortcode_cleaner' );

function my_remove_shortcode(){
    return '';
}
share|improve this answer
1  
Always seem to be on the ball with your answers, just wanted to take a moment and say nice to have you as part of the community here Joshua. – t31os Dec 10 '11 at 16:49
    
Thanks a lot t31os... my pleasure :) – Joshua Abenazer Dec 10 '11 at 16:55
1  
Pleasure is all mine, only takes a moment to give valued members a little praise and i've been upvoting on alot of your answers recently, so it's well deserved.. ;) – t31os Dec 10 '11 at 16:58
    
Sorry, no dice. I had figured this out a while back but lost it during a migration. And thanks again for all your other answers! – Teknophilia Dec 10 '11 at 19:33

Thanks to Joshua's answer, and that's life saving indeed. :)

BTW, I can propose a slightly different method. Suppose you have created a plugin and now you are going to release its pro version - so you have the full control over both the plugins, so you can follow something like this:

Actual Plugin:

if( !function_exists('wpse36092_shortcode') {
   function wpse36092_shortcode() {
       echo 'This'; //existing content
   }
}
add_shortcode( 'wpse36092', 'wpse36092_shortcode' );

Pro Plugin:

function wpse36092_shortcode() {
       echo 'That'; //overwriting content
}
add_shortcode( 'wpse36092', 'wpse36092_shortcode' );

In this method, the name of the function should remain exact same.

You can do the same thing in your Parent theme and Child theme too.

But again, Joshua's answer was great.

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.