WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] I want a header image only on the Home page (7 posts)

  1. boruts
    Member
    Posted 1 year ago #

    Hello,

    i'm new to WordPress and i really like all the options and adjustments on Twenty Twelve theme, but i can't find the option, where i can set the header image will show up only on Home page (first page) and not on all other pages. So i'm thinking that some changes in one of the .php files should solve my problem, but i dont know where and what or how should i do that, help me please.

    Thank you

    --
    Borut

  2. alchymyth
    Forum Moderator
    Posted 1 year ago #

    start by creating a child theme to make the customisations with; http://codex.wordpress.org/Child_Themes

    then edit header.php in the chid theme; add a conditional statement around the header image code to check for the home page - or because a conditional statement already exists, modify that;

    existing line:

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

    for example, change that to:

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

    http://codex.wordpress.org/Conditional_Tags

  3. boruts
    Member
    Posted 1 year ago #

    Thank you alchymyth for your answer, but i really have to make child theme just to do that?

  4. alchymyth
    Forum Moderator
    Posted 1 year ago #

    really have to make child theme just to do that?

    the answer is more a 'should' than a 'must';

    technically, you can edit the theme directly -
    but you shouldn't for the following reasons:

    - working with a child theme will keep modifications safe when the (parent theme) theme is updated;
    - an unedited parent theme, if it is one of the WordPress default themes, is important as a fallback in case of other serious theme problems;

  5. boruts
    Member
    Posted 1 year ago #

    Well that worked great, i created a new child theme, then created a new style.css and then i have also copied header.php from parent theme to child theme and edited the lines just like you said and my header image is now only on home page :)

    Thank you very much for the instructions mr. alchymyth.

    But now i have a new problem, how to rename Home button into About or something else for example. I cant copy functions.php file from parent folder, but i must create a new and empty functions.php file in order to make a changes for child theme. So what command should i use to rename Home button and how to make this in functions.php file in child theme.

    Please help :)

  6. alchymyth
    Forum Moderator
    Posted 1 year ago #

    how to rename Home button into About or something else for example.

    make sure the new functions.php starts with <?php in the first line (nothing before that whatsoever)

    in the functions.php in the child theme, add for example:

    add_filter( 'wp_page_menu_args', 'twentytwelvechild_page_menu_args', 20 );
    
    function twentytwelvechild_page_menu_args( $args ) {
    	$args['show_home'] = 'About or something else';
    	return $args;
    }

    http://codex.wordpress.org/Function_Reference/wp_page_menu

    or alternatively, consider to use the custom menu option dashboard - appearance - menus http://codex.wordpress.org/Appearance_Menus_Screen

  7. boruts
    Member
    Posted 1 year ago #

    Great, thank you zillion times alchymyth for your kind help :)

Topic Closed

This topic has been closed to new replies.

About this Topic