How to put title OVER the header image in Twenty Eleven
-
Hi, I created a few days ago this blog.
I use a child from Twenty Eleven theme. I would like this configuration in the header. In practice I would like the configuration of the header image like when you select from appearance -> header -> display text -> no BUT with the text on the image instead of no text at all. I hope I explained myself πCan someone help me?
Thank you and best regards
-
well…
1. Copy the header.php from /themes/twentyeleven to your childtheme directory
2. Open it and find the following lines (at line 99 by default)
<?php // Has the text been hidden? if ( 'blank' == get_header_textcolor() ) : ?> <div class="only-search<?php if ( ! empty( $header_image ) ) : ?> with-image<?php endif; ?>"> <?php get_search_form(); ?> </div> <?php else : ?> <?php get_search_form(); ?> <?php endif; ?>
Delete it… take care that you are editing in your childthemes header.php
3. Create an empty functions.php or if you already have your own, use this. Add this between the <?php and ?>
//add search field to nav-menu function fb_add_search_box ( $items, $args ) { // only on primary menu if( 'primary' === $args -> theme_location ) $items .= '<li class="menu-item menu-item-search">' . get_search_form( FALSE ) . ''; return $items; } add_filter( 'wp_nav_menu_items', 'fb_add_search_box', 10, 2 );
4. Add this to your style.css in your childtheme directory
/* Search Form in Menu */ #access #searchform { position: static; float: right; padding-top: 6px; padding-right: 4px; } #access input#s { background-color: #505050; border-color: #7c7c7c; } /* blog title */ #branding hgroup { position: absolute; }
5. Change the text-color in your theme-settings (backend) to a better fitting one like white π
Hope this will do β let me know…
[mod: reminder: keep the posted code to 10 lines max – for more use the pastebin]
Hi Egado, thank you very much for your big reply!
I followed all your instructions, and now the text is OVER the header π β¦ but the search form isn’t displayed. I checked twice the procedure and I followed it right.
A minor side effect is that now all header image works as a link to the home of the blog (I don’t know why).
You can check the result hereThank you again
hmm… now the text is on the correct position or?
The Header is a link to the blog home by default π we’ve changed β nothing this is twentyeleven itself πsearchform… can you pls post your full functions.php from your childtheme directory? (if it has more that 10lines pls use http://pastebin.com/ ) π
Yes, the title is exactly where I wanted (over the header image), thank you!
About the “link side effect” I was talking about the header image. I know header title is a link, but now it is also almost all the image.Here you are my functions.php
<?php add_action( 'after_setup_theme', 'my_child_theme_setup' ); add_filter( 'wp_nav_menu_items', 'fb_add_search_box', 10, 2 ); function my_child_theme_setup() { remove_filter( 'body_class', 'twentyeleven_body_classes' ); } function fb_add_search_box ( $items, $args ) { if( 'primary' === $args -> theme_location ) $items .= '<li class="menu-item menu-item-search">' . get_search_form( FALSE ) . ''; return $items; }?>
Thank you for your help
hmmm… in my twentyeleven theme the hole image is a link by default… should we change it, so that only the text is a link?
ok… wrong filter, my fault pls delete the old code from step 3 π and replace it with this new one…
//add search field to nav-menu add_filter( 'wp_page_menu', 'fb_add_search_box', 10, 2 ); function fb_add_search_box ( $items, $args ) { $items .= '<li class="menu-item menu-item-search">' . get_search_form( FALSE ) . ''; return $items; }
so your functions.php sould look like this
<?php add_action( 'after_setup_theme', 'my_child_theme_setup' ); //add search field to nav-menu add_filter( 'wp_page_menu', 'fb_add_search_box', 10, 2 ); function fb_add_search_box ( $items, $args ) { $items .= '<li class="menu-item menu-item-search">' . get_search_form( FALSE ) . ''; return $items; } ?>
Well, I would prefer if only the title is a link a not the whole image.
The search field is now correctly displayed. I realigned it myself with the sidebar, changing the padding in child styles.css
#access #searchform { position: static; float: right; padding-top: 6px; padding-right: 155px; }
But when I click on it extends on the “wrong” direction (left instead of the right). Is it possible to change this?
And last but not less important: how can I exchange all the help you are giving to me? Really, is there a way?
Thank for your patience
Header-Image-Link
1.)
Open your header.php (childtheme directiry) and search for
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
delete it2.)
Delete also the closing</a>
(probable somewhere in line 94-98)3.)
Save, Upload, Done πSearch-Field-Direction
I will try to figure out whats the right solution for you… will getinng some trouble with the positioning π dont know if i can fix it this night… but here is a litte update for your functions.php … that will not fix the extending direction but another little mistake… π<?php add_action( 'after_setup_theme', 'my_child_theme_setup' ); //add search field to nav-menu add_filter( 'wp_page_menu', 'fb_add_search_box', 10, 2 ); function fb_add_search_box ( $items, $args ) { $items .= get_search_form( FALSE ) . ''; return $items; } ?>
…oy my…
exchange all the help… yes there is a way… try to help others if you can π thats all πHeader image now is only a static image, thank you!
The new function you gave me deleted a ‘β’’ char in the menu, near the link “Manuel’s web page”. I have noticed before, but with all the help you were (and are) giving to me I didn’t find the courage to ask for such a small thing like that.
I don’t know if I will be able to help others, I know pratically nothing about CSS and PHP but surely I can reply to the frequently asked question that everyday new people ask because they don’t use the search feature π
my first test worked π
childtheme style.css update like it follows:
#access #searchform { position: static; float: right; padding-top: 6px; padding-right: 265px; } #access input#s { background-color: #505050; border-color: #7c7c7c; position: absolute; }
//EDIT
I have try to mark π the changes… pls delete the<strong> </strong>
in the css πtested in Firefox, Chrome and IE8…
It worked but I had to remove those tags. May be it was a formatting error during editing.
My blog now is exactly like I dreamed π If you give me an URL I will cite you in my site credits (if you’d like).
Thank you for all your help!
I saw your edit after my message π
Well I’m going to bed, will check tomorrow morning for your reply. All technical questions are solved.
I don’t know if you still can reply if I marked the thread as solved, so I will wait till tomorrow morning to mark as solved.
Thank you for all your help and good night.Good job, looking pretty now π
And sorry for my english… its hard to explain sometimes…Yeah, that would be nice, but just a little link to http://www.egado.de I’ll still working on the layout… hope my blog is gonne be launched this year π
You’re Welcome!
Your English was completely clear.
I made the credit page: http://manuelmagic.me/wordpress/?page_id=86Thank you for everything.
Byedamn… now i’m a little bit moved to tears β BIG THX for your credits π
And have a lot of fun with your blog…
- The topic ‘How to put title OVER the header image in Twenty Eleven’ is closed to new replies.