WordPress.org

Ready to get started?Download WordPress

Forums

Telling the difference between a page and a post inside search.php (2 posts)

  1. madhavaji
    Member
    Posted 5 years ago #

    I've pasted the code in question below (cutting out unnecessary stuff).

    My question is, how, just before <div class="p-det"> can I determine whether the individual search result I'm outputting is a post or a page. I don't want to list categories or comments for pages but I do for posts ...

    Any help much appreciated :)

    m.

    -->

    '<?php while (have_posts()) : the_post(); ?>
    ...
    <div class="p-det">

      <li class="p-cat">In: <?php the_category(' |') ?>
      <li class="p-com"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?>

    </div>
    ...
    <?php endwhile; ?>'

  2. MichaelH
    Member
    Posted 5 years ago #

    I'm guessing that the $post->post_type could be tested to be 'page' or 'post'.

Topic Closed

This topic has been closed to new replies.

About this Topic