• Resolved Carl V

    (@carlos-amigos)


    In Options>Reading I have set a static home (home.php) page and a news page (news.php), and wanted to add some conditional coding to my sidebar (if is news page then show categories else show image, which is a random number output ‘rand(3,5)’), but for some reason it is not working? so is it “is_page”, “is_page(‘news’)” or something else? as it is not coming up?

    <?php if ( is_page('news') ) : ?>
    <?php wp_list_categories('show_count=1&title_li='); ?>
    
    <?php else : ?>
    
    <div id="sideImage_<?php echo $myRandomVariable; ?>">
     <!-- Insert Header Image Here -->
    </div>
    
    <?php endif; ?>

    Thanks
    Carl

Viewing 5 replies - 1 through 5 (of 5 total)
  • moshu

    (@moshu)

    Just for clarification:
    You do NOT set files in the Options > Reading! You set Pages created in Write > Write Page as front and posts page, respectively.
    And don’t make a Page template with the filename home.php because it will confuse every setting!

    As for your question – as strange as it is, try to use is_home.

    On the other hand, for the “static” frontpage it seems that is_page(page-slug) should work.

    Thread Starter Carl V

    (@carlos-amigos)

    Maybe my understanding is off on how to create a static home and post page? (Can you please clarify if what I am doing is the correct way of doing it, or if there is an easier way to do it.)

    Here is what I have done:
    1) Created a home.php page
    2) Created a news.php page
    3) Created a Page called news (slug) and told it to use news.php as its template
    4) Created a Page called home and told it to use home.php as its template
    5) Then in Options>Reading I have said to use static home & post pages

    So, home has specific text on it (just a few paragraphs and that is it – so no posts at all)

    What I am after is the news (slug) page as I call the function is_page(‘news’) but nothing happens? or does not set my conditional statement to true?

    Thanks

    moshu

    (@moshu)

    This is just wrong wording:
    1) Created a home.php page
    2) Created a news.php page

    Thjose are NOT pages – those are template files.

    #4. DO not name a Page template as home.php. “home.php” is a reserved template file name – do not use it!

    or does not set my conditional statement to true?
    It is not true… and I answered above. Did you read it? Did you try it?

    Thread Starter Carl V

    (@carlos-amigos)

    Just to clear that up – No I didn’t name a “Page” (slug “home.php”) I created a template file called home.php (just clearing that up).

    Never mind I just saw what it was doing and have fixed the problem…

    Thanks

    * the solution for me was when I set the home as a Page it could be called is_page where as the news Page (slug news) was called is_home so I had the terminology mixed a little on what is what..

    Thanks

    moshu

    (@moshu)

    You got the conditional part right… but you still don’t get the home.php issue. Learn: Template_Hierarchy

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘If static post page is set what is it? is_page?’ is closed to new replies.