X Theme & Pro Theme

Override the Pro Theme header assignment for specific pages and conditions

X Theme & Pro Theme14 Comments

Themeco’s Pro Header Builder is pretty amazing. From it’s in depth controls to endless styling options, anyone can make a truly magnificent header. But what do you do when the specific page you’d like to target isn’t available as an assignment? How about when you want to show a specific header for logged in users? Or for different user roles?

This little PHP snippet will do just that. But first, 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:

Simple as that!

What else can you do with this code? Well, how about your 404 page?

How about a different header for logged in users?

And for user roles? Here’s one for authors:

How about assigning headers to multiple pages?

You get the idea. Feel free to mix and match as needed to create the custom header assignments you need for you site.


Like what you see? Then get it in your inbox.

  • This field is for validation purposes and should be left unchanged.
Notify of
Newest Most Voted
Inline Feedbacks
View all comments

First off thanks for posting this I have been searching for this for a while and wasnt getting much help from Themeco Support.

I am not a developer so this may seem like a dumb question. I used the snippet for the search page and then tried to use the snippet for the 404 page but I received an error on my functions.php. How do I combine the 2? They are both using the same header ID #.

Anne van der Heijden

Thank you for this tutorial. I’ve been looking for something like this for a while.
Since I’m quite new to code I don’t really know what I’m doing. I was hoping to set a header per product-category. Could you please help me with this?

I was now using:

// Header assignment
// =============================================================================
add_filter('cs_match_header_assignment', 'custom_search_header');
function custom_search_header($match) {

  $product_category = wp_get_product_category();

  if (in_array( 'huiden', (array) $product_category )) {

    $match = 418; // the post ID for your header


  return $match;


But this gives an internal error. I’d very much appreciate your help!
Thanks in advance!

Last edited 2 years ago by Michael Bourne
Anne van der Heijden

Thank you so much for your quick reply. I’ll go and try this with the information you’ve given! 🙂


Thanks for your tutorial, Michael! Seemed simple enough, but not knowing php has me in a bit of a bind 😉

I need to assign my header to the forums page (BB Press), but the following code gave me a white screen instead. I’m guessing “is_forums” is incorrect.

Here’s what I added to functions.php:
add_filter('cs_match_header_assignment', 'custom_search_header');
function custom_search_header($match) {
if (is_forums()) {
$match = 214; // the post ID for your header
return $match;

Can you please point me in the right direction? Thanks 🙂


Jacob Dietz

This is great info, but I’m wondering if you can accomplish something similar with categories? i.e. all posts using the ‘blog’ category get the assigned blog header and all posts using the ‘news’ category get the news header. Possible?


Hi, awesome! Is this possible dynamically with the results of a zipcode finder plugin? For instance, my client has 5 service areas, and I would love to change the footer to apply to the service area (which is based on the results of the zipcode finder plugin).

Its a bit complicated I think, and if necessary I would be happy to hire you or someone to help.

Samuel Thériault

Hi, It seem that the category is only looking at the last part in the URL. So if you have a parent category and also a child category it will only use the child for filtering. This is the code I’m using to sort the post page display for different header add_filter(‘cs_match_header_assignment’, ‘custom_search_header’); function custom_search_header($match) { if ( is_archive(”) and in_category(‘residences’) ) { $match = 3453; // the post ID for your header } elseif ( is_archive(”) and in_category(‘events-19-20’)) { $match = 4110; // the post ID for your header } return $match; } One of my header is applied… Read more »


Just a little syntax correction that give a a bit of a headache.
5th line is missing a ) before the {

    if ( is_category('residences') {

Should be:

    if ( is_category('residences')) {

Otherwise thank you a lot for that

Last edited 2 years ago by Samuel