0
私は2つの別々のループを持つことができるコードを見つけたので、2つの異なるカテゴリに検索結果を表示できます。Wordpress検索結果カテゴリ別に複数のループ
このコードを修正すると、ループごとに「結果が見つかりません」というメッセージが表示され、2番目の「ブログ」カテゴリのみページングを追加することができます。トップの「ショップ」に最大6件の結果が表示されます。 。任意の助け
<?php
get_header(); ?>
<div class="content">
<?php
$s = get_search_query();
?>
<div class="search">
<div class="categoryThumbs">
<?php if (have_posts()) : ?>
<h3><?php printf(__('Search Results for: %s'), '<span>' . get_search_query() . '</span>'); ?></h3>
<?php endif;?>
<?php query_posts("s='$s'&category_name=shop"); ?>
<?php if (have_posts()) : ?>
<?php $blogResults=0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$blogResults++;
?>
<?php endwhile; ?>
<h4><?php echo $blogResults; ?> Results in Shop</h4>
<?php while (have_posts()) : the_post(); ?>
<div class="films">
<div class="thumb">
<a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a>
</div>
<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>
<div class="entry">
<?php the_excerpt() ?>
</div>
</div>
<?php endwhile; ?>
<?php endif;?>
<?php query_posts("s='$s'&category_name=blog"); ?>
<?php if (have_posts()) : ?>
<?php $blogResults=0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$blogResults++;
?>
<?php endwhile; ?>
<h4><?php echo $blogResults; ?> Results in Blog</h4>
<?php while (have_posts()) : the_post(); ?>
<div class="films">
<div class="thumb">
<a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a>
</div>
<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>
<div class="entry">
<?php the_excerpt() ?>
</div>
</div>
<?php endwhile; ?>
<?php endif;?>
<div class="spacer"></div>
</div>
</div>
ありがとう!