'How can I show different headers for custom post type drop down template in wordpress
I have a Custom post type called cme-education which has a drop down to select a custom post type template (similarly how you would with a page template drop down for pages in wordpress). When I select the template, it works however, I want to be able to show a different header for that template but I am not sure how to achieve that.
my code for the drop down CPT template is in template-in-conversation.php file
<?php
/*
Template Name: IN CONVERSATION
Template Post Type: cme-education
*/
?>
<?php get_header(); ?>
and then I have a header file which has an if statement to show the associated headers based on the condition header.php file
if(is_singular('in-conversation')){
get_template_part('includes/headers/header_in_convo');
} else {
echo "not found";
}
Solution 1:[1]
You need to add a custom header file for that like header-in_convo.php.
Then you could do this:
if(is_singular('in-conversation')){
get_header( 'in_convo' );
} else {
echo "not found";
}
See here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Cray |
