Pro header for portfolio category

Hi

After some research on the forum I found a workaround for getting a Pro Header to display on post categories, should this work with portfolio categories as well or will it need adjusting? The slug and ID shown here are the correct ones.

function custom_header_assignment( $match ) {
if ( is_single() ) {
if ( in_category( ‘current-projects’ ) ) {
$match = 300; // the post ID for your header
}
}
return $match;
}
add_filter( ‘cs_match_header_assignment’, ‘custom_header_assignment’ );

Hello @henrybag,

Thanks for writing to us.

Unfortunately, assigning headers to the category or archive pages aren’t possible. But you can check and implement the workaround here Header assigned to a Post category. Basically, it’s just about the filter cs_match_header_assignment . And you can utilize that filter to control how the header is displayed. The code provided in that thread is just a guide, you shouldn’t add/use it as is, and you still need to change it to make it work to your preferred setup. Example

function custom_header_assignment( $match ) {
  if ( is_category() ) {
      $match = 1234; // the post ID for your header
  }
  return $match;
}
add_filter( 'cs_match_header_assignment', 'custom_header_assignment' );

If you just follow what’s provided in that thread then it will not really work, please keep in mind that we don’t maintain the code. What was provided is just the backbone, the rest is up to you.

Thanks

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