• hi everybody.
    my search results look like this:

    <?php if (have_posts()) : ?>
    
    		<h1>Search Results</h1>
    
    		<ul class="dates">
    		 	<?php while (have_posts()) : the_post(); ?>
    			<li>
    				<span class="date"><?php the_time('n.j.y') ?></span>
    				<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
    				Published on
    				<?php the_category(', ') ?>
    			</li>
    			<?php $results++; ?>
    			<?php endwhile; ?>
    		</ul>

    the only problem i have with it is that pages don’t have categories, and so they show in the list in a broken sentence, like this:
    “ABOUT ME published on”

    what can i do to so that the “published on” will not show after names of pages in the list?

    thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Maybe try:

    <?php if($post->post_type != 'page') : ?>
    Published on
    <?php the_category(', '); ?>
    <?php endif; ?>

    Thread Starter niros

    (@niros)

    thanks!
    your offer excluded pages from the results completely. i did something similar but a little different:

    <?php if (have_posts()) : ?>
    	<h1>Search Results:</h1>
    		<ul class="dates">
    	 	<?php while (have_posts()) : the_post(); ?>
    		<li>
    		<span class="date"><?php the_time('n.j.y') ?></span>
    		<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
    		<?php if($post->post_type != 'page') : ?>Published On
    		<?php the_category(', '); ?>
    		<?php endif; ?>
    			</li>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘how to modify pages appearence on search results?’ is closed to new replies.