If statement PHP.. Wordpress

3 replies
Ok Im using this

Code:
<?php if(is_home()) : ?>
<h1><a href="<?php echo get_option('home'); ?>"><?php bloginfo('name'); ?></a></h1>
<?php else : ?>
<span id="blogTitle">
<a href="<?php echo get_option('home'); ?>"><?php bloginfo('name'); ?></a>
</span>
<?php endif; ?>
On My wordpress blog...

My homepage is a static wordpress page, so I need the blog title to be at least included on that page.

It includes my blog title but doesnt put it in the code on that page or any other page.

it's good that it's removed everything from my other pages as now I have a nice clean <H1>

But for the homepage I want it to at least include this, any ideas..

What I do to that code to make it right?

Oh the homepage is set via General settings in wordpress back office, so that it is the statci page I've selcted it to be.

It is called home but i guess the if statement is wrong because it isn't picking it up.

Cheers
#php #statement
  • Profile picture of the author tunasalad
    Try this out instead:

    <?php if(is_home()) { ?>
    <h1><a href="<?php echo get_option('home'); ?>"><?php bloginfo('name'); ?></a></h1>
    <?php } else { ?>
    <span id="blogTitle">
    <a href="<?php echo get_option('home'); ?>"><?php bloginfo('name'); ?></a>
    </span>
    <?php } ?>


    the open and close braces are key. wrap them around the entire contents of your if and else clauses.
    {{ DiscussionBoard.errors[776065].message }}
  • Profile picture of the author esoomllub
    I'm not quite sure exactly what you mean in your description, but as for the code, have you tried replacing is_home() with is_front_page()? Is_front_page will handle a home page that is either a page or a post listing (default wordpress).
    Signature
    {{ DiscussionBoard.errors[776846].message }}
  • Profile picture of the author esoomllub
    I can't post links here yet (until I get to 15 posts), but if you search at google for "wordpress developer documentation" the first result will be their documentation.

    I sometimes find it less than easy to use. I often find that a google search for "wordpress" and then the function I am looking to find out about usually will put me at the right place within their documentation quicker.
    Signature
    {{ DiscussionBoard.errors[776950].message }}

Trending Topics