Forums

[resolved] is_home() not showing up using conditional (5 posts)

  1. CSSgirl
    Member
    Posted 2 years ago #

    I think somewhere I must have mixed up some code/syntax because my conditional isn't working correctly.

    What it is supposed to do is show a post blurb on the home page in one spot if it's the home page. If not, then show a form. Currently, it is showing the form on the home & other pages, and the post blurb isn't showing.

    Here is the code:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    What'd I do wrong :( ?

  2. CSSgirl
    Member
    Posted 2 years ago #

    Changing it and simplifying it down to:

    <?php if ( is_home() ) { ?>
                 Test
             <?php }
    		 		else {  ?>
       					 <div id="resources">
                	Test 2
                </div><!-- end resources -->
    				<?php	}   ?>

    Test 2 shows on homepage :/ ...

  3. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    http://codex.wordpress.org/Function_Reference/is_home

    alternatively try:
    http://codex.wordpress.org/Function_Reference/is_front_page

    if your site is running other queries before this conditional statement, the querystring might be distorted - try to add wp_reset_query(); before the if statement.

  4. CSSgirl
    Member
    Posted 2 years ago #

    Well, digging around I found this, which says, just add <?php wp_reset_query(); ?> before your conditional and it will reset all previous queries and make your conditional work.

    And it worked :D

    Hope that helps someone else!

    -Lindsey

  5. necati
    Member
    Posted 2 years ago #

    I am having problems with this as well and wp_reset_query won't work either.

    I am on WP 3.1

Topic Closed

This topic has been closed to new replies.

About this Topic