1
4

1 回答 1

2

The important file is search.php, which displays any matching results, or a failure message if there are no matches. Try something like this:

<?php
/**
 * Search results page
 */
?>
<?php if ( have_posts() ): ?>
<h2>Search Results for '<?php echo get_search_query(); ?>'</h2> 
<ol>
<?php while ( have_posts() ) : the_post(); ?>
    <li>
            <h2><a href="<?php esc_url( the_permalink() ); ?>" title="Permalink to <?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
            <time datetime="<?php the_time( 'Y-m-d' ); ?>" pubdate><?php the_date(); ?> <?php the_time(); ?></time> <?php comments_popup_link('Leave a Comment', '1 Comment', '% Comments'); ?>
            <?php the_content(); ?>
    </li>
<?php endwhile; ?>
</ol>
<?php else: ?>
<h2>No results found for '<?php echo get_search_query(); ?>'</h2>
<?php endif; ?>

<?php get_sidebar(); ?>
<?php get_footer(); ?>
于 2012-12-03T23:52:06.893 回答