WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Show Search Results as Excerpts (7 posts)

  1. Fletcher Davies
    Member
    Posted 1 year ago #

    Hi, currently when i search something on my WordPress site it displays the full page in results. I would like it to automatically display the results as excerpts:

    My code in search.php is as follows:

    <?php 
    
    /**
     *
     * search.php
     *
     * The search results template. Used when a search is performed.
     *
     */
    
    get_header(); ?>
    <div class="ttb-layout-wrapper">
        <div class="ttb-content-layout">
            <div class="ttb-content-layout-row">
                <div class="ttb-layout-cell ttb-sidebar1">
                  <?php get_sidebar('default'); ?>
                  <div class="cleared"></div>
                </div>
                <div class="ttb-layout-cell ttb-content">
    			<?php get_sidebar('top'); ?>
    			<?php
    				if(have_posts()) {
    
    					theme_post_wrapper(
    			  			array('content' => '<h4 class="box-title">' . sprintf( __( 'Search Results for: %s', THEME_NS ),
    			  				'<span class="search-query-string">' . get_search_query() . '</span>' ) . '</h4>'
    			  			)
    			  		);
    
    					/* Display navigation to next/previous pages when applicable */
    					if (theme_get_option('theme_top_posts_navigation')) {
    						theme_page_navigation();
    					}
    
    					/* Start the Loop */
    					while (have_posts()) {
    						the_post();
    						get_template_part('content',get_post_format());
    					}
    
    					/* Display navigation to next/previous pages when applicable */
    					if (theme_get_option('theme_bottom_posts_navigation')) {
    						 theme_page_navigation();
    					}
    
    				} else {
    					theme_404_content(
    						array(
    							'error_title' => __('Nothing Found', THEME_NS),
    							'error_message' => __('Sorry, but nothing matched your search criteria. Please try again with some different keywords.', THEME_NS)
    						)
    					);
    
    				}
    		    ?>
    			<?php get_sidebar('bottom'); ?>
                  <div class="cleared"></div>
                </div>
            </div>
        </div>
    </div>
    <div class="cleared"></div>
    <?php get_footer(); ?>

    Any assistance would be appreciated.

  2. francomusso
    Member
    Posted 1 year ago #

    Hi seivadf,
    The code you provided makes use of a custom function named theme_post_wrapper. It's a little difficult to help at the moment without seeing that function.

    Which theme are you using?

  3. Fletcher Davies
    Member
    Posted 1 year ago #

    Hi francomusso, thanks for the reply:

    Im using a custom theme that i have built with a program called artisteer.

    Would it help you if i posted the functions.pho here also??

  4. francomusso
    Member
    Posted 1 year ago #

    Yes, please do. If it's a long file, I'd suggest you use something like pastebin and then provide a link here.
    All the best,
    Franco

  5. Fletcher Davies
    Member
    Posted 1 year ago #

    Franco,

    Here is my functions.php file from my theme

    functions.php

  6. Fletcher Davies
    Member
    Posted 1 year ago #

    Franco,

    You can now view the website at http://www.mccarthy.nsw.edu.au.
    I still can get it to auto summarize my search results.

    Cheers

  7. Fletcher Davies
    Member
    Posted 1 year ago #

    I found a plugin that automatically display the searcg results as excerpts

    Auto Excerpt Everywhere

    Cheers for you help

Topic Closed

This topic has been closed to new replies.

About this Topic