How to create more than 2 headers & footers for a custom template

Hi,

Firstly i’m not interested in using plugins to do this – I’m creating my own theme and CPTs Roles etc without plugins. I’ve just learned its possible to have an alternative; 2nd header and footer for specific pages of the site and its working ok. However when i repeat the exercise to create a 3rd variation it just loads the default, header.php, footer.php and page.php. None of the tutorials ive learned from online actually explain if its possible to have a 3rd variation or even fourth.

When i use a 2nd header & footer (as below respectively) on the new page thus:

if( is_page('page-log') ) { get_header('log'); }
else { get_header(); }

if( is_page('page-log') ) { get_footer('log'); }
else { get_footer(); }

It works as expected – when i add a 3rd condition and create all the required page thus:

if( is_page('page-log') ) { get_header('log'); }
elseif( is_page('app-dash') ) { get_header('app'); }
else { get_header(); }

if( is_page('page-log') ) { get_footer('log'); }
elseif( is_page('app-dash') ) { get_footer('app'); }
else { get_footer(); }

the default header and footer (in the else clause) and default page.php load and not the new 3rd page.

Any idea what’s going on here or is it just not possible to have 3 or more alt headers and footers in your template?

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer