X Theme & Pro Theme

Override the Pro Theme header assignment for specific pages and conditions

X Theme & Pro Theme7 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.

Leave a Reply

Notify of

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
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!


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 šŸ™‚