0

I removed/unregistered the theme (BirdTIPS) header images, but the default header image is still displayed. How to remove it programmatically (not css or editing header.php)?

My code:

add_action( 'after_setup_theme', 'remove_default_headers', 11 );

function remove_default_headers() {
    remove_theme_support( 'custom-header', array(
        'default-image',
    ) );
    unregister_default_headers(
        array(
            'green',
            'blue',
            'yellow',
            'red',
            'white',
            'orange',
            'pink',
            'purple'
        )
    );
}

In the header block of the header.php there is this code (I want to avoid to edit it, nor in the child theme):

    <?php if ( ! empty( $birdtips_header_image ) ) : ?>
            <?php if ( 'blank' == get_header_textcolor() ): ?>
                <a href="<?php echo home_url( '/' ); ?>"><img src="<?php header_image(); ?>" alt="<?php bloginfo( 'name' ); ?>" ></a>
            <?php else: ?>
                <img src="<?php header_image(); ?>" alt="<?php bloginfo( 'name' ); ?>" >
            <?php endif; ?>
    <?php endif; ?>
  • have you looked into your active theme's header.php? – Gopal S Rathore Aug 3 '15 at 13:31
  • Yes, I have there a line <img src="<?php header_image(); ?>" alt="<?php bloginfo( 'name' ); ?>" >. But if the image was removed by the above function, why it is loaded? Sorry for my ignorance, I am not a programmer. – Iurie Malai Aug 3 '15 at 13:41
  • What theme are you using? – Brad Dalton Aug 3 '15 at 18:22
  • A BirdTIPS child theme. wordpress.org/themes/birdtips – Iurie Malai Aug 3 '15 at 18:51
1

As You have stated in comment that You have disabled header images, but its still returning default image.

Explanation : It depends on how it was coded in the theme by the developer. For an instance, it seems like if you disable all header images, it returns Default header set by the developer / theme.

Now, Even if the function header_image() doesn't returns anything, <img> tag will be there and a placeholder or Alt Text will appear on the page, that is not a proper solution/way to remove header.

  • So, I must to edit the header.php? – Iurie Malai Aug 3 '15 at 14:33
  • 1
    yes you will have to edit and remove that tag. – Gopal S Rathore Aug 4 '15 at 1:05
1

Yes, unfortunately, it looks like you'll have to edit the header.php and remove the tag from there. Even if you disable the default image on there, the image tag will still show in your html.

Since you're using a child theme, what's the risk of editing your child theme's header.php?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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