Community Forums › Forums › Archived Forums › General Discussion › How do you make a hook on only the home page?
Tagged: genesis_after_header, is_front_page
- This topic has 8 replies, 4 voices, and was last updated 8 years, 8 months ago by
Brad Dalton.
-
AuthorPosts
-
May 9, 2017 at 10:27 am #206184
carnelldesign
MemberI want to put a full length image below the header on just the home page. This is easy to accomplish an all pages but NOT just one page.
Do I do this in functions.php and if so how do you put it just on the home page? Or should I make a home page template and if so what code do I put into the template to display the graphic?
https://www.orlandographicscompany.comMay 9, 2017 at 10:55 am #206187Victor Font
ModeratorOff hand it looks like you're already using a custom page template for the home page. You are definitely using a custom built theme, so without access to your code, it's not possible to provide guidance. I would contact the developer that built the theme for you.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?May 9, 2017 at 12:53 pm #206201Andrea Rennick
MemberWordPress code uses php conditionals to do things on specific pages.
http://codex.wordpress.org/Conditional_Tags
**forum signature**
If you need technical support for your theme please file a ticket.The forums are community based. Staff only monitors the forum for issues relating to the forum itself and to redirect users to where they need to go.
May 9, 2017 at 2:31 pm #206206Brad Dalton
ParticipantThere's at least 4 ways you can add your image after the header using the genesis_after_header hook.
1. Add the code directly to your themes existing front-page.php or home.php file.
2. If your theme doesn't include a front_page.php file, create one and add the code in either file.
3. Hook the image in via a custom function in your child themes functions file using (as Andrea suggested ) a conditional tag like:
if ( is_front_page() )
4. Add a widget after the header and add the HTML for your image to a text widget in the after header widget area.
May 9, 2017 at 3:50 pm #206208May 10, 2017 at 2:55 am #206232carnelldesign
MemberThanks! For some reason method 2 isn't working. I did get method 3 to work. But I need more customization. Any idea how to add HTML below the header?
May 10, 2017 at 3:08 am #206234carnelldesign
MemberI actually got it working with method 3. I noticed that had a div tag in there. So it worked out perfect! Thanks 🙂
May 10, 2017 at 8:44 am #206246carnelldesign
MemberSo "if ( is_front_page() )" calls to the home page. What if I want to put it on a different page? Like my about us page.
May 10, 2017 at 3:28 pm #206256Brad Dalton
ParticipantPlease use this page about conditional tags on the WordPress Codex as a guide.
As you can see, there are several methods.
Note : All methods are tested and working.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.