• Resolved Po Dong

    (@podong)


    I want change header’s background image through WordPress back-end.

    Current solution:

    create a post called, ‘background image’. The content of it is empty but has a featured image.

    In my header.php, I use code as below:
    <header style="background: url('<?php echo wp_get_attachment_url( get_post_thumbnail_id($post_id));?>') no-repeat top center / cover;">

    So, I can change the background image by giving a new featured image to the post of ‘background image’.

    Is there any better way to achieve that?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @po Dong,
    WordPress provides header image uploader by default. If you go to theme-customizer via Appearance, you will see a section called header image. Upload your image there and then you can use <?php echo( get_header_image() ); ?> to call the header-image wherever you want it.
    Hope that helps!
    Thanks!

    Thread Starter Po Dong

    (@podong)

    Thank you @wen Solutions,
    I guess having this function really depends on which theme is used. I currently use a child theme of ‘Mustang Lite’. So, there is no such function. Could you please explain how to have this function in my theme?

    Thread Starter Po Dong

    (@podong)

    I found a solution which add this function to my theme. Thanks for providing the right direction.

    Reference:

    How to Enable Custom Header Images Panel in WordPress 3.0

    Great to hear that. If you have any further query, kindly post it; else mark this ticket as resolved.

    Thanks!
    CHEERS!

    Thread Starter Po Dong

    (@podong)

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to change background images for 'header' tag’ is closed to new replies.