if is_home Help Please? (4 posts)

  1. Chris H
    Posted 4 years ago #

    Hi everyone,

    I've got an issue I'm hoping someone can help with. I'm building a template that features a custom field pulled into an H2 tag in the header. It's basically a two sentence description on what the page is about. No worries on any of the pages, but I'm trying to figure out how to get the same thing to happen on our blog/posts page.

    This is my first try using the is_home function, but I can't seem to get it working. Can anyone help me out and tell me what is wrong with the following code? I've tried putting it inside the <head> tags and the <body> tags, but it doesn't seem to make a difference.

    <?php if(is_home()) {
    	<h1 class="page-heading">This is our fancy, shiny blog!</h1>
    	} else {
    	<h1 class="page-heading"><?php echo get_post_meta($post->ID, 'Page Heading', true); ?></h1>

    Thanks everyone.



  2. Michael
    Part-Time Forum Moderator
    Posted 4 years ago #

  3. Chris H
    Posted 4 years ago #


    Thanks for your reply.

    My "home" page (the page the site opens on) is set to display a static WordPress page. The blog/posts section of the site is accessed via a menu item called "Blog".

    I believe the technique I'm using is the correct one, however I suspect I've got an issue with the code I'm using (previous post). I'm editing in Coda, and once I get to the first opening H1 tag, Coda stops "color-coding" my code as it normally would. I've uploaded a screen shot so you can see what I mean:


    Any further thoughts?



  4. money-maker
    Posted 4 years ago #

    Hi, I tried to use is_front_page and is_home once without any success. What I ended up doing was using a function to pull current URL and comparing with base URL, or whatever homepage you use. So essentially built a custom homepage checker, it's not hard and there's code out there if you search.

Topic Closed

This topic has been closed to new replies.

About this Topic