0

I'm using a child theme that only has video post format, but parent theme defines all post formats:

add_theme_support( 'post-formats', array( 'gallery', 'link', 'image', 'quote', 'video', 'audio', 'chat' ) );

I tried:

remove_theme_support( 'post-formats' ); add_theme_support( 'post-formats', array( 'video' ) );

But is not working. How can I do this without modifying parent theme?

2 Answers 2

1

It's import to set the priority for your after_setup_theme higher than your parent theme. The default priority is 10. Using the twentysixteen as example, use priority 11 on child themes' 'after_setup_theme' action. Exemple below:

function twentysixteen_child_setup() {
    add_theme_support( 'post-formats', array(
        'video',
    ) );
}
add_action( 'after_setup_theme', 'twentysixteen_child_setup', 11 );
1

Make sure that you're not just calling these functions within functions.php, but calling them at the right time with add_action(). Try the following:

// in your Child Theme's functions.php    

// Use the after_setup_theme hook with a priority of 11 to load after the
// parent theme, which will fire on the default priority of 10
add_action( 'after_setup_theme', 'remove_post_formats', 11 ); 

function remove_post_formats() {

    remove_theme_support( 'post-formats' );
    add_theme_support( 'post-formats', array( 'video' ) );
}

What's likely happening is that you're attempting to remove theme support before it's even added.

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.