WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how to know if excerpt on search page is page or post? (3 posts)

  1. forgetcolor
    Member
    Posted 3 years ago #

    in loop.php, how can i test whether the current post being worked on is a Page or a Post? when on a search or tag results page, i want to show post dates only if the result is a Post, but not if it's a Page.

    i've tried is_page() and $wp_query->is_page but can't get it.

    thanks!

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

    <?php
    $posttype = $post->post_type;
    if($posttype == 'post') { the_time(); }
    ?>
  3. forgetcolor
    Member
    Posted 3 years ago #

    aaawwwesome, thx!

Topic Closed

This topic has been closed to new replies.

About this Topic