• Resolved jagreen

    (@jagreen)


    Hi folks!

    My search function is retrieving entire pages after a search term is entered. I don’t want it to do that. I just want to see short descriptions of my pages come up. The site is https://timeforjazz.com.

    What should I do about this? Thanks!

    [Edit]
    Perhaps I should have mentioned that I’m using this code:

    <form name=form1 method=”get” action=”https://timeforjazz.com/”&gt;
    <input type=”text” name=”s” id=”s” size=”32″ class=”searchform-textbox” value=”Type & Hit Enter to Search” onclick=”document.form1.s.value =”;”>
    </form>

Viewing 6 replies - 1 through 6 (of 6 total)
  • check your theme folder. usually, theme has file name search.php. This file use on showing search result

    find this code (below)

    the_content()

    and change it in to

    the_excerpt()

    See the_excerpt on wordpress codex

    Thread Starter jagreen

    (@jagreen)

    Thanks, uwiuw. My theme’s search file is searchform.php, but it does not contain this piece of code. Other ideas? Or another place I could find this part of the code?

    Use the search.php file in the default theme as a template for your own search template file.

    Thread Starter jagreen

    (@jagreen)

    Still having trouble. Are you saying I should copy and paste the code from search.php into the searchform.php code in my theme? Either way, search.php in the default theme doesn’t seem to contain that piece of code either. It looks like this:

    <?php get_header(); ?>
    
    	<div id="content" class="narrowcolumn">
    
    	<?php if (have_posts()) : ?>
    
    		<h2 class="pagetitle">Search Results</h2>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    		</div>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div class="post">
    				<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>
    				<small><?php the_time('l, F jS, Y') ?></small>
    
    				<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">No posts found. Try a different search?</h2>
    		<?php include (TEMPLATEPATH . '/searchform.php'); ?>
    
    	<?php endif; ?>
    
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    My searchform.php looks like this:

    <form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
    <?php if (strlen(get_search_query()) > 0) { ?>
    	<input type="text" onfocus="if (this.value == '<?php the_search_query(); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php the_search_query(); ?>';}" value="<?php the_search_query(); ?>" name="s" id="s" />
    <?php } else { ?>
    	<input type="text" onfocus="if (this.value == 'Search') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search';}" value="Search" name="s" id="s" />
    <?php } ?>
    
    </form>

    The code i’ve copied and pasted into a text widget (since I like the disappearing text in the text box) is this:

    <form name=form1 method="get" action="https://timeforjazz.com/">
    <input type="text" name="s" id="s" size="32" class="searchform-textbox" value="Type & Hit Enter to Search" onclick="document.form1.s.value ='';">
    </form>

    What I want is for the search results to come back with excerpts (like I was using a search engine) and not just the whole pages/posts stacked on top of one another.

    i have read your code (search.php) then put the_excerpt() in the position just like this

    <small><?php the_time('l, F jS, Y') ?></small>
     <?php the_excerpt() ?>
     <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments ?', '1 Comment ?', '% Comments ?'); ?></p>

    see now you have the_excerpt() between the_time and the_tags

    Thread Starter jagreen

    (@jagreen)

    Beautiful! Thanks so much for your help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Search Retrieves whole pages’ is closed to new replies.