ワードプレス検索では、私はポストタイプの "製品"だけを検索しようとしています。 しかし、まだ私の "ジャーナルポスト"を表示しています。 "search-everything"というプラグインを使用して、タグなどのいくつかの余分な投稿機能(私はすべての靴製品に「靴」というタグをつけていて、製品内に「靴」という単語を使用していました) Wordpressのは、任意の検索プラグインなしでもに見えるものですタイトル、 これとは別に、検索テンプレートがきちんと働いている「商品投稿」検索で「雑誌」と表示されるのはなぜですか?
それをテストするためのウェブサイトを見てください。上記http://jadepalacecollective.com/?s=shoes
例"mules"の検索です また、ジャーナル(下の大きな画像)から投稿を取得しています
これは私のコードです(私は読みやすさのためにそれをスリム化している) search.phpが、それは、テンプレート検索コンテンツをフェッチ何かを見つけた場合、私が最初にこのメインsearch.phpページへ
<?php
if (get_post_type() == 'product') : ?>
<header class="page-header">
<h1 class="page-title searchresults-for"><?php printf(esc_html__('Search Results for: %s', 'palace'), '<span>' . get_search_query() . '</span>'); ?></h1>
</header><!-- .page-header -->
<?php
/* Start the Loop */
while (have_posts()) : the_post();
get_template_part('template-parts/content', 'search');
endwhile;
else :
get_template_part('template-parts/content', 'none');
endif; ?>
を行きます.phpを実行すると、製品に関する情報が表示されます。
<?php if (get_post_type() == 'product') : ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(); ?>
</a>
</article><!-- #post-## -->
<?php endif; ?>
これはなぜ起こっているのでしょうか。間違って何かしていますか?
ニースでそんなに簡単にこのコードを使用して、特定のポストタイプの検索結果を絞り込むことができます。多くの感謝のアレックス。 –