I understand you can add extra CSS on top of the parent theme, but how do you remove PHP code from functions.php?

I want to remove the Masonry plugin in twentyfourteen theme, and have located the piece of code on line 254.

    if ( is_active_sidebar( 'sidebar-3' ) ) {
    wp_enqueue_script( 'jquery-masonry' );
    }

If I’m editing the parent theme, I can just comment this block out /* */.

But I’m not aware of a way to change this is my child theme.

2 Answers
2

You can’t actually “remove” PHP code from the parent theme. What you can do is undo things done there.

The counterpart of wp_enqueue_script is wp_dequeue_script.

If you put this in your functions.php it should remove the Masonry Plugin (untested)

add_action( 'wp_print_scripts', 'de_script', 100 );

function de_script() {
    wp_dequeue_script( 'jquery-masonry' );
}

Source: Function Reference/wp dequeue script @ Codex

As I haven’t tested this be aware of the fact that this could have unwanted side effects if the theme relies on the Masonry Plugin.

Leave a Reply

Your email address will not be published. Required fields are marked *