Removing Theme Support from a Parent Theme Using a Child Theme

I was just doing some messing around with removing features from a parent theme, most specifically looking at something like infinite scroll. At first, I thought you could just do it with:

remove_theme_support('infinite-scroll');

But as it turns out, that won’t work.

Instead, you need to find a place to run that. So create a new action and make sure it runs after the parent theme. Parent themes run at priority 10, so set this up at priority 11. This will work:

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

function child_alter_parent_theme()
	{
		remove_theme_support('infinite-scroll');
	}

Put that in your child theme’s functions.php and it will remove infinite scroll (as an example). You can add as many things as you want to remove there and it should take care of all of them.

One comment on “Removing Theme Support from a Parent Theme Using a Child Theme

Comment navigation

  1. One best practice I like to follow when using non-standard priorities, e.g. `11, is to add an inline comment stating why.

    “`
    add_action( ‘after_setup_theme’, ‘child_alter_parent_theme’, 11 ); // we need this to run after the parent theme has been initialized
    “`

Comments are closed.