I'm developing a site using a child theme of GeneratePress. I'd like to remove some parent theme action hooks via functions.php, but only when the post/page is using a Toolset Content Template. In other words, if the post/page doesn't have a Toolset content template assigned, the child theme does nothing. Is this possible?
I ended up with this in my functions.php file... Do you see any issues with doing this? Am I using the correct hook ('wp')?
add_action( 'wp', 'sbgd_remove_parent_actions' );
function sbgd_remove_parent_actions() {
global $post;
// Returns the ID of the assigned Content Template or 0 if there is no one
$has_ct_assigned = has_wpv_content_template( $post->ID );
if ( $has_ct_assigned > 0 ) {
// Has a Content Template assigned.
add_filter( 'generate_show_entry_header', '__return_false' );
remove_action( 'generate_after_header', 'generate_featured_page_header', 10 );
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single', 10 );
} else {
return;
}
}