I’m trying to create a custom post template for feeds of a certain category of posts, but more of an X template with global blocks as opposed to a wordpress php file… I’ve already got the template set up with X, and would just like to overwrite everything else when any child category of a certain parent category is being displayed.
I created a child theme and have the following in functions.php:
add_filter( 'single_template', function ( $single_template ) {
$parent = '11'; //Only CTIDE category
$categories = get_categories( 'child_of=' . $parent );
$cat_names = wp_list_pluck( $categories, 'name' );
if ( has_category( 'CTIDE' ) || has_category( $cat_names ) ) {
$single_template = dirname( __FILE__ ) . '/single-ctide.php';
}
return $single_template;
}, PHP_INT_MAX, 2 );
From there I’m wondering if I can just insert the global blocks (just a header and footer) into my feed-ctide.php template in order to avoid having to get too in the weeds with a new template php file.
Any advice appreciated. Thanks