WordPress.org

Ready to get started?Download WordPress

Forums

search.php only show headlines of PAGES?? (2 posts)

  1. sepp88
    Member
    Posted 4 years ago #

    hey guys,
    i wonder how i could solve the following problem:
    my search.php uses <?php the_excerpt(); ?> to show the search results. If the search-query also shows PAGE-results (not only single-posts) the excerpt of a page might look weird, due to the fact, that most of my pages use listings and so the excerpt gets abnormal long and bursts the website.

    I wonder if I could somehow exclude the_excerpt of Pages in the search-results and show only the Headlines (permalinks) of PAGES???

    Is this even possible?

  2. asdfg asdf
    Member
    Posted 4 years ago #

    You want to display only the post title on the search result?

    Try this to your search.php

    <?php if (have_posts()) : ?>
    
    		<h2 class="pagetitle">Search Results</h2>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div <?php post_class() ?>>
    				<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    
    			</div>
    
    		<?php endwhile; ?>
    
    	<?php else : ?>
    
    		<h2 class="center">No posts found. Try a different search?</h2>
    		<?php get_search_form(); ?>
    
    	<?php endif; ?>

    But make sure you have a backup of your original search.php

    Hope this would help..

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.