• I have a small button that floats with my content to shoot people back up top on long pages.

    I would like for this to not show on the index page so I’m trying to figure out the is_home conditional tag stuff.

    I simply have the image placed with fixed positioning and I’m using this to display it…

    <a href="#top"><img src="<?php bloginfo('template_directory'); ?>/images/top.png" id="toplink"/></a>

    I would like for that to be ignored on home but used everywhere else and I cannot figure out how to structure the conditional code.

    Anyone up for helping me?

    Thanks!

    (PS – you can see it in use here: http://jamesmeister.com/)

Viewing 11 replies - 1 through 11 (of 11 total)
  • <?php if ( ! is_home() ) : ?>
    <a href="#top"><img src="<?php bloginfo('template_directory'); ?>/images/top.png" id="toplink"/></a>
    <?php endif; ?>
    Thread Starter JamesM

    (@righton)

    I used that and I’m still seeing it pop up on the home page.

    Keep in might there is a difference between the front page and the home page. Basically, the “front” page is the top level of your site; the “home” page is wherever the latest posts are listed, which when there’s a static front page is not the top level page. One of is_home() or is_front_page() should do what you want.

    Thread Starter JamesM

    (@righton)

    I’ve used is_home and is_front_page and both still show up on the main front page.

    I use is_front_page in most of my projects, so you could use

    <?php
    if (!is_front_page())
    {
    ?>
    
      <a href="#top">
        <img src="<?php bloginfo('template_directory'); ?>/images/top.png" id="toplink"/>
      </a>
    
    <?php
    }
    ?>

    Remember what the Codex says

    is_front_page()
    When it is the front of the site displayed, whether it is posts or a Page. Returns true when the main blog page is being displayed and the ‘Settings->Reading->Front page displays’ is set to “Your latest posts”, or when ‘Settings->Reading->Front page displays’ is set to “A static page” and the “Front Page” value is the current Page being displayed. Note: this tag was added at Version 2.5.

    Thread Starter JamesM

    (@righton)

    Strange… no matter how I seem to phrase the conditional (all of the examples above) it never vanishes from the front page.

    Could it be that I have renamed index.php to all.php and have rewritten index.php to only pull up the main category and include all.php?

    I’m using this for index.php

    <?php
    $_GET['cat'] = "1";
    include "all.php";
    ?>
    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Could it be that I have renamed index.php to all.php and have rewritten index.php to only pull up the main category and include all.php?

    Yes, that could do it. Don’t do that.

    If you want the category to be forced to 1 on the index page, then there are much better ways. query_posts(‘cat=1’); for example.

    Thread Starter JamesM

    (@righton)

    I use that for each “page” I want, to pull out one category per “page”.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Okay, but why? I mean, category pages are built in. http://example.com/category/whatever/, for example.

    Thread Starter JamesM

    (@righton)

    is that something you need to build in? I just tried jamesmeister.com/graphic_design/ and it didn’t work.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    a) You need to be using non-default permalinks to get that sort of style of URL.

    b) The word “category” is not optional. You can change it though, look at your Settings->Permalink page.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘is_home conditional help’ is closed to new replies.