views:

11

answers:

2

I am modifying a wordpress template and need to slightly separate rendering logic for a post and a page, specifically in relation to how the date renders out. The problem is that I cannot find any code to do this, I am sure that it exists. Is there a variable that exists within wordpress that tells me whether the item being displayed is a page or a post?

In an ideal world it would look something like this:

<?php if (is_page()) : ?>
    page logic
<?php else: ?>
    post logic

Would appreciate any help!

A: 

Pages are a type of post, so get_post_type should return appropriately different values for pages vs normal blog posts.

Charles
Thank you very much for your response, but this only looks to work inside a loop from what I see. I need something that also works when you are viewing a single page.
Michael Ransley
Ah yes, The Loop, my nemesis, we meet again!
Charles
A: 

I found this link: http://wordpress.org/support/topic/sidebar-logic-for-postblogroll-and-page-type which seemed to do the business for me.

The answer (copied straight from the page) was:

<?php if(is_singular($post)): ?>
Page Content
<?php else:?>
Post Content
<?php endif;?>
Michael Ransley