Adding post-formats to Twenty Ten child theme

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):

Read More
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?

Related posts

Leave a Reply

2 comments

  1. 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.

  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.