How do I make my image header only appear on my homepage? Also, how do I edit code in WordPress to fix this?
You can use this wordpress function is_front_page() to for this kind of thing, Simply add if condition
if(is_front_page()) {
/*your header image goes here and you condition*/
}
You have multiple ways for doing this either you can use header.php or you can make a home page template and write this condition this your home page template.
Related
I am new in WordPress,
I want to know how to add footer other then default footer
( example: Footer file name - home-footer.php and need to use for home page, same as contact-us-footer.php for contact us page ). let me how i can achieve this.
if you are adding your files in theme or WordPress core files then this will automatically remove when your WordPress will be updated unless you creat child theme so just better to create to footers with any page builder I recommend elementor and then hide that with page id you will find that in the body tag of every page like this
.page-id-111 .footer{
display:none;}
Let me know if you don't understand anything
You have to name the file footer-home.php. Then you can call this footer in the page template (i.e. page-home.php) using get_footer('home').
Wordpress will use the right file, if it is named correctly starting with footer-*.php.
Not sure if this is only problem for Elementor full width template, but it seems to override theme header.php. I tried achieving my goal by using elementor custom code feature, but it adds my code somewhere in middle of the tag.
What is the propper way of adding my own custom code as the first thing that is after the element?
You are right Elementor overrides the theme's header.php file so importing your code to this file is not effective. You need to add custom function to earn your goal. With the wp-head action you could add the code right into your header and Elementor will not override it.
Add this code to the functions.php file od your active theme.
add_action('wp_head', 'custom_head_function');
function custom_head_function(){
?>
YOUR HEADER CODE HERE
<?php
};
UPDATE - If you want to set your code at the top
As sephsekla mentioned in comment, there is a way to set the priority into your action to get it to the top. Try to set value to -999. So, choose a very low number and if there is no other lower number in your plugin or theme you will go straight to the top.
add_action('wp_head', 'custom_head_function', -999);
function custom_head_function(){
?>
YOUR HEADER CODE HERE
<?php
};
Elementor now supports custom code (javascript, html, etc) and supports the specific use of elements in the head of the page.
What you are looking for you can find at the Wordpress Dashboard> Elementor > Custom Code . Then you will be able to add a custom code to the head: https://elementor.com/help/custom-code-pro/
I have inserted an image in wordpress theme header.And now the image shows in all wordpress pages.I want to avoid that please help me.
Well, in that case you can use the conditional tag, For example, if you want to display the image in only contact page, then u can use this code: if(is_page( 'Contact' )) { Put your image code here } where Contact is the title of that page
Hope it helps.
I want to use a different header style for the home page than for inside pages of my site. Specifically, I want the header section to be less tall on the inside pages. Should I use a different header.php file for the home page? If so, how?
I'm having a hard time getting ideas using Google, so if anyone has a helpful link to the appropriate resource that'd be great.
WordPress has a home page boolean function is_front_page() (true if is front page otherwise false)
Add a class to the header/body/whatever parent so
<header class="header<?php if(is_front_page()){ ?> home_header<?php } ?>">
</header>
and simply reference the class in CSS.
WordPress codex reference
For example I'm create new page in wordpress "page3" I want edit html and css of this page and add for example my contacs, how to do this ?
I'm searching in theme options, but no resut.
You can edit the page.php file but what you do to it will effect all other pages. Or you can duplciate the page.php file and call it page-3.php (Or whatever your "Page3" page ID number is). Be sure to keep the calls for the header and footer and the tops and bottoms of your page .