Custom Post Type does not display header or footer

I am using Pro theme with the Integrity stack on a new WordPress 5.8 site. Pro Theme version 5.0.8. Pro - Child Theme version 1.0.0.

I used the Header Builder to create a header and in the Assignment Conditions applied it to the Entire Site. This header appears on the standard pages of the site, but does not appear on the custom post type archive and single post pages built by the WP Auto Listings plugin (version 2.5.14).

Note: I found a very similar topic from July 2020 that was marked as closed without the resolution being shared: Custom Post Type does not display header, footer, or page layout

Based on the discussion in the topic form July 2020, I contacted the developers of WP Auto Listings and asked how to call the default get_header and get_footer from their plugin. They shared these details with me:

The plugin’s templates are designed to be overridden. Details at: https://wpautolistings.com/docs/templates/

You can find the file archive-listing.php and single-listing.php in the templates folder then change the function get_header( “listings” ); to the default get_header();

I overrode the get_header() and get_footer() method calls in both the archive-listing.php and single-listing.php files as suggested by the plugin developer. Unfortunately, this had no effect - the header still does not display on these pages. I deactivated all other plugins on the site, but the header still does not display. I switched active themes to Twenty TwentyOne and a header does display on those pages.

Please advise on what needs to be configured / coded within Pro or the child theme to enable the Auto Listings plugin to build pages that have header and footer built in Pro applied to them successfully.

Hi @S4X4CO,

Thank you for writing in, you might need customization to apply your header/footer on those custom posts type. For the custom development you will need to have a Child Theme installed and follow the steps here.

Hope it helps,
Cheers!

Thank you for the link. As mentioned previously, I am using the Pro - Child Theme v 1.0.0.

I would be grateful for more specific guidance please. The link provided includes details on how to set specific headers for Search pages (if (is_search())), 404 pages (if (is_404())), and for logged in users/roles. What is the logic condition required to set the header for all pages created by the WP Auto Listings plugin?

i.e.

add_filter('cs_match_header_assignment', 'custom_header');

function custom_header($match) {
	
	if ( /* What goes here? */ ) {
		$match = 23; /* The header post ID */
	}
	
	return $match;
}

Similarly, how can the global footer be applied to the pages built by the WP Auto Listings plugin?

Hi @S4X4CO,

You can make a condition to check if that post belongs to that specific post type. If Listing is the post type created through this plugin, the example code will look like the following.

if ( get_post_type( get_the_ID() ) == 'listing' ) 
{

}

You can find more details in this article: http://justintadlock.com/archives/2011/07/20/conditional-checks-for-custom-post-types

As you have overridden the hook cs_match_header_assignment for the Header, you can use the cs_match_footer_assignment hook for the Footer in a similar way.

Hope it helps.
Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.