overflow
Member
Posted 9 months ago #
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!
See Conditional Tags and the is_page() conditional.
overflow
Member
Posted 9 months ago #
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.
overflow
Member
Posted 9 months ago #
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';
}
overflow
Member
Posted 9 months ago #
Yes! Exactly what I wanted :) Thanks a lot!