Support » Fixing WordPress » remove date/time from entry if it is a page, in search results

  • Resolved overflow

    (@overflow)


    My search.php loops whatever returns the ?s= query

    I’d like to edit my search.php further so that if the entry being displayed is a page, the date/time is not shown.

    How do I detect, from inside the loop, if the currently being dumped entry is a page, to code accordingly?

    Many thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • See Conditional Tags and the is_page() conditional.

    Yes, I tried that… it’s like this:

    <div id="container">
    <?php if(have_posts()) : ?>
    <?php while(have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    
    <div class="post_header">
    
    <?php if( is_page() ) { echo "PAGE!"; } ?>
    
    <h2>" title="<?php the_title(); ?>">
    <?php the_title(); ?></h2>

    In concrete the part

    <?php if( is_page() ) { echo "PAGE!"; } ?>

    But it never shows the PAGE! string as I wished…

    As far as I understood, the is_page() is to detect if the current big render is a page… in this case it is a search.

    the code ticks don’t work so well apparently, the code i pasted ended up a bit messed up, but i think u get the idea. thanks!

    Probably cause it’s a search page…

    See if this works:

    if ($post->post_type=='page') {
    echo 'page';
    }

    Yes! Exactly what I wanted 🙂 Thanks a lot!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘remove date/time from entry if it is a page, in search results’ is closed to new replies.