Support » Fixing WordPress » Search Results, not loading the_excerpt

  • I’m using a custom code for my search page, the query seems pretty straight forward but for some reason it’s not loading any content… can someone help me out? My code is as follows:

    <?php
                        $my_searchterm = trim(get_search_query());
                        if($my_searchterm !='') : ?>
    
    					<?php if (have_posts()) : // posts found ?>
                            <div class="privacytos-box">
                                <h3><?php the_title();?></h3>
                                <?php the_excerpt();?>
                                <p style="text-align: right; font-size: 11px;"><a href="<?php the_permalink();?>">More &rarr;</a></p>
                            </div> 
    
                        <?php else : // No posts found ?>
                            <h3>Your search for <?php $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; _e(''); _e('<span class="search-terms">'); echo $key; _e('</span>'); _e(' yielded '); echo $count . ' '; _e('Results'); wp_reset_query(); ?></h3>
                            <p>Please try again</p>
                            <form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
                                <input type="text" name="s" id="s" value="" placeholder="">
                                <input type="submit" id="searchsubmit" value="Search">
                            </form>                
    
                        <?php endif;?>
                        <?php else : // no search term was entered ?>
                        You did not enter a search term, please try again.
                            <form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
                                <input type="text" name="s" id="s" value="" placeholder="">
                                <input type="submit" id="searchsubmit" value="Search">
                            </form>
                        <?php endif; ?>

    I’m unsure as to where I’ve gone wrong, the site I pulled the code from was posted in 2011, but since the title loaded I wasn’t sure why the actual post has gone missing.
    http://quirm.net/2011/08/31/a-better-wordpress-search/ – This is the site.

    Please help?? 🙁

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Search Results, not loading the_excerpt’ is closed to new replies.