所以我有以下通过邮政类型过滤器吐出,但我怎么可以使用类别或自定义字段?基于类别的搜索结果
$categories = array(
'post' => 'Articles',
'mobile-experience' => 'Mobile',
'staff-profiles' => 'Staff Profiles',
'events' => 'Events',
'page' => 'Page Content',);
我只是想改变wordpress搜索结果页面来填充它们的类别。
EG。搜索关键字汽车。
类别1
汽车(此类别中找到汽车项目)
类别2
汽车(汽车项目此类别中找到)
类别3
未找到(此类别中没有发现汽车项目)
等
通过关键字搜索车。
会抓住任何与关键字汽车和类别下填充(项目进行了下2个分类发现关键字汽车,而不是3;到处在那里发现将填充)
基本上而不是拍摄出与关键词汽车所有项目;它会显示搜索到的关键字汽车类别下的结果。
我只有3个类别。
最近尝试(尝试2种)
<?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=build"); ?>
<?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;?>
<?php query_posts("s='$s'&category_name=apps"); ?>
<?php if (have_posts()) : ?>
<?php $blogResults=0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$blogResults++;
?>
<?php endwhile; ?>
<h4><?php echo $blogResults; ?> Results in Films</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>
</div>
<?php get_footer(); ?>
您是否在考虑'array_merge()'也许?你有没有一个你想要做什么的例子? – Rasclatt 2014-10-29 21:35:26