Avoid Custom header for Archieve pages of CPTS

Hi !
I have set up some cpts and separate headers for each one.My problem is with ARCHIEVE pages.When I set up any header to cpt then it automatically assigns to Archieve page…which is not suitable for me.Is there any way to avoid this? (I want to assign global header to archieve page)

Hi There,

First, you have to installed and activated the child theme first: https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57.

Second, you need to get the post ID of the header you’d like to assign. The easy way to do that is to simply hover over the Edit link in the builder, and take a look at the URL in your status bar. It should look similar to domain.com/x/#/headers/1234

That 1234 is the post ID you need for this snippet. Want a custom header on your search results page? Place this in your child theme’s functions.php file:

add_filter('cs_match_header_assignment', 'custom_archive_header');
function custom_archive_header($match) {
	if ( is_post_type_archive('custom_post_type_slug') ) {
		$match = 1234; // the post ID for your header
	return $match;

For more information about the is_post_type_archive function, please take a look at this: https://codex.wordpress.org/Function_Reference/is_post_type_archive.

Hope it helps :slight_smile:

It Works !
Thanks !

You’re most welcome!

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