WordPress.org

Ready to get started?Download WordPress

Forums

[closed] Moving header image to top of page (11 posts)

  1. clivelive
    Member
    Posted 1 year ago #

    Hi,
    Complete novice who has researched current solutions to this problem but they make no sense (to me!) I'm using 2012 and would like to move the header image to the top of the page and superimpose it over my title. I've looked at the page, style, header php templates but can't find where/what to include/delete from the CSS code. It can't be that difficult can it?

  2. jamesg40
    Member
    Posted 1 year ago #

    Move this code from line 48 of the header.php. Cut and paste this`<?php $header_image = get_header_image();
    if ( ! empty( $header_image ) ) : ?>
    <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /></a>
    <?php endif; ?>`

    To just below this at line 36

    <header id="masthead" class="site-header" role="banner"> and that will move the header up above everything.

  3. jamesg40
    Member
    Posted 1 year ago #

    PS be sure that you actually cut the code from line 48 and below down to <?php endif; ?> and when you paste it, make sure that you don't paste it over the other code thustly deleting something that's needed.

  4. clivelive
    Member
    Posted 1 year ago #

    Wow, it worked!....many thanks jamesg40.....it looks great.Pushing my luck a bit but is there a way to select a different header image on each page?

  5. jamesg40
    Member
    Posted 1 year ago #

    Sure it can be done but There wont be an easy way (like point and click options.)I don't think the theme has the option built in. I mean the solution is not too difficult but depending upon which way you handle it could be time consuming. One way could be to create an admin panel, build in the wp media uploader and write some code behind it, another way could be to replicate page templates and assign a div class to each of the header parts on each page template and style that div class with a different background-image:{} and select the page template for each page you want a different header on. Otherwise your stuck writing a bit of php and creating some variables and arrays and such, lol. I think its a shortcut and easier to simply do the page templates if its just for your site and not for a client.

  6. leejosepho
    Member
    Posted 1 year ago #

    Many thanks!

  7. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    @clivelive - Hopefully, you're already using a child theme, but if not, you should be! It's not a good thing to make changes to theme files - as you will lose all your changes when WP is updated and you really must have a clean copy of the default theme for troubleshooting purposes. Please see the linked page on Child Themes and go back and make a child theme before doing any further work on your site.

    http://codex.wordpress.org/Child_Themes

    Once you have the child theme set up, you can put the modified header.php file in the child and replace the parent header.php file with a clean, newly downloaded copy of that file only via FTP. If you've changed other files, you should do the same with them.

  8. clivelive
    Member
    Posted 1 year ago #

    Thanks, WPyogi, hadn't thought of that...will do

  9. jamesg40
    Member
    Posted 1 year ago #

    Yes, yes.... WPyogi is absolutely correct. Many Thanks for adding that WPyogi, I didnt think of it when I answered. Child theme would be the way to go.

  10. guddu1315
    Inactive
    Posted 10 months ago #

    Hi
    i want to display unique header image for each page through admin panel..... how can i do that? And 1 thing more i do not want to use any plugin...so help me out...
    thanks

  11. WPyogi
    Volunteer Moderator
    Posted 10 months ago #

    @guddu1315 - please start your own thread and include more info in your thread per http://codex.wordpress.org/Forum_Welcome#Where_To_Post

    You can start a new thread here:

    http://wordpress.org/support/forum/how-to-and-troubleshooting#postform

Topic Closed

This topic has been closed to new replies.

About this Topic