4

So I have been building a child theme for a site. Wanted to add post formats to a twentyten child theme. Now, the goal of my child theme is to copy over the absolute least amount of code/templates from the parent as possible.

I originally figured if I added additional post formats to a twentyten child theme, using a custom function which uses add_action after_setup_theme, it would work. However, that does nothing. Something like (either with or without the 2 existing formats, doesn't matter):

function voodoochild_setup(){

add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link' ) );
}

add_action( 'after_setup_theme', 'voodoochild_setup' ); 

The only way I've found to add post formats, is to copy the entire twentyten_setup action to my child functions.php from twentyten, and edit that small portion from there, adding my formats.

This works fine, and I'm cool with it. I just want to know if it's necessary. Is there a better way to register new formats onto a child theme without hauling that big block of code over to the child?

2 Answers 2

4

Try bumping the priority of your hook, like so:

add_action( 'after_setup_theme', 'voodoochild_setup', 11 );

This will ensure that it runs after the TwentyTen formats setup, so that it gets the last laugh. That's how I do it on WordPreh.com.

0
2

EDIT: Dougal posted the same thing whilst i was writing my response, but i'm posting mine anyway, +1 Dougal.

The parent theme formats will override the childs, and vice versa depending on which occurs first, what you can do though is hook onto after_setup_theme after the parent theme has done so and redefine them, like so..

add_action( 'after_setup_theme', 't31os_setup', 11 );
function t31os_setup(){
    add_theme_support( 'post-formats', array( 'aside', 'gallery', 'image', 'quote' ) );
}

TwentyTens setup function runs at priority 10(default), so as long as we run the above filter after that we get control over the formats.

3
  • Appreciate you taking the time to answer as well! Ahh... simple things eh? I've only just started figuring out the priority thing.... so I forget to use it often Commented Mar 8, 2011 at 18:33
  • No problem at all, took me all of about 2 minutes to work out.. ;)
    – t31os
    Commented Mar 8, 2011 at 18:37
  • "Dougal posted the same thing whilst i was writing my response..." Heh, happens to us all. :) Commented Mar 8, 2011 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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