Custom-header for Category Listing

This question is slightly different from what was previously asked (which was also very helpful).

Is there a way to assign a custom-header for Category Listing… not for a single post but the listing of posts by Category.

Hello @sgchan,

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 https://theme.co/forum/t/header-assigned-to-a-post-category/74699/2. 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.