テンプレートにsearch.phpファイルを追加し、ユーザーをこのページを検索するには、このページが表示され、あなたはこのような必要なものを表示することができます:
<?php
get_header(); ?>
<section id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php if (have_posts()) : ?>
<header class="page-header">
<h1 class="page-title"><?php printf(__('Search Results for: %s', 'twentyfifteen'), get_search_query()); ?></h1>
</header><!-- .page-header -->
<?php
// Start the loop.
while (have_posts()) : the_post(); ?>
<?php
/*
* Run the loop for the search to output the results.
* If you want to overload this in a child theme then include a file
* called content-search.php and that will be used instead.
*/
get_template_part('content', 'search');
// End the loop.
endwhile;
// Previous/next page navigation.
the_posts_pagination(array(
'prev_text' => __('Previous page', 'twentyfifteen'),
'next_text' => __('Next page', 'twentyfifteen'),
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __('Page', 'twentyfifteen') . ' </span>',
));
// If no content, include the "No posts found" template.
else :
echo "NOTHING FOUND";
endif;
?>
</main><!-- .site-main -->
</section><!-- .content-area -->
とコンテンツ-search.phpに(このファイルはあなたのテーマにする必要があります):
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title(sprintf('<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url(get_permalink())), '</a></h2>'); ?>
</header><!-- .entry-header -->
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php if ('post' == get_post_type()) : ?>
<footer class="entry-footer">
<?php twentyfifteen_entry_meta(); ?>
<?php edit_post_link(__('Edit', 'twentyfifteen'), '<span class="edit-link">', '</span>'); ?>
</footer><!-- .entry-footer -->
<?php else : ?>
<?php edit_post_link(__('Edit', 'twentyfifteen'), '<footer class="entry-footer"><span class="edit-link">', '</span></footer><!-- .entry-footer -->'); ?>
<?php endif; ?>
が 私のテーマの仲間の努力をありがとうマスター研究Wordpressのテーマは、あなたができることですこのテーマが含まれているかどうかを確認してください。私も検索しています –
このファイルを追加しても、それがなくてもテーマに論理を追加できます。 –
ありがとうございますWhatever :-) –