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; ?>
4
  • have you looked into your active theme's header.php? Commented Aug 3, 2015 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.
    – Yuri
    Commented Aug 3, 2015 at 13:41
  • What theme are you using? Commented Aug 3, 2015 at 18:22
  • A BirdTIPS child theme. wordpress.org/themes/birdtips
    – Yuri
    Commented Aug 3, 2015 at 18:51

2 Answers 2

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.

2
  • So, I must to edit the header.php?
    – Yuri
    Commented Aug 3, 2015 at 14:33
  • 1
    yes you will have to edit and remove that tag. Commented Aug 4, 2015 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 and acknowledge you have read our privacy policy.

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