WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using a child theme of twenty-twelve, and want to remove the huge banner image in the header for certain post types. How can I use add_filter() or add_action() to do this? I don't want to mess with the header.php file in the parent theme, I just want to preg_replace the HTML content that the header has. Excuse my ignorance, but I am fairly not versed in WP yet.

share|improve this question

Copy header.php to your child theme so you're not editing the parent theme's file. And on line 49, you will see this line of code:

if ( ! empty( $header_image ) ) : ?>

This says if header image is not empty show the header image. So you can add to that condition to check for any post type you want. Like this example:

if ( ! empty( $header_image ) && get_post_type() !== 'my-posttype' ) : ?>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.