How can one differentiate between posts and pages in search results?
What I need to do is show a the_time
div for posts but not show it for pages, as it’s irrelevant.
With a function? <?php if (!is_page()) }
in the loop below doesn’t help.
<?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
//prevent this div from displaying for pages:
<div class="searchdate"><?php the_time('F jS, Y') ?></div>
<?php the_excerpt(); ?>
<?php endwhile; ?><?php else : ?><?php endif; ?>
Try this…
The
is_page()
conditional tag only checks if currently displayed content is a single page view. Nothing for you at this point. See http://codex.wordpress.org/Function_Reference/is_page