这是一个repeat of this question,因为我在SO上得到更快的答案。Wp电子商务元信息搜索
开箱即用,WP电子商务不支持元搜索。如果您在网上销售图书并且需要客户能够通过最重要的Meta标签进行搜索,那么这是个大问题。
有人可以告诉我怎么可以去包括元信息搜索还是有更好的插件,不花费胳膊和腿来搜索元信息呢?
编辑:
因为我已经找到了一个插件,会做一个名为Relevanssi和亚历山大Gieg更好的搜索扩展它远一点用他自己的代码:
add_filter('relevanssi_excerpt_content','wpscproductexcerpt',10,3);
function wpscproductexcerpt($content, $post, $query) {
if ('wpsc-product' == relevanssi_get_post_type($post->ID)) {
$content = $post->post_content . (!empty($post->post_excerpt) ? " $post->post_excerpt" : '');
if ('on' == get_option('relevanssi_expand_shortcodes')) {
$content = do_shortcode($content);
} else {
$content = strip_shortcodes($content);
}
// The line below fixes a minor bug in Relevanssi 2.9.14 custom excerpt generating code:
$content = preg_replace("/\t/", ' ', $content);
}
return $content;
}
因为我是Visser Lab's Custom Field's plugin用户,所以我需要能够进一步扩展这一点,以弥补WP电子商务的不足之处,并且需要弄清楚如何包含元信息从这个插件?
非常感谢
你知道[WordPress Meta Queries](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters)吗?我没有时间检查WP电子商务插件的代码,但基本上,如果您可以连接到插件制作的查询,则可以添加一个自定义Meta Query,其中包含您的自定义字段。 'meta_query'查询参数是一个数组或多个数组,其中一个包含'key'(自定义字段名称),'value'(要匹配的值),'compare'(比较运算符),'type'(是否它的文本,数字,日期等) –
嗨尼古拉。 WP电子商务利用WP的通用搜索。那么我是否应该勾选WP的查询来进行搜索? – SixfootJames
是的 - [这里](http://wordpress.org/support/topic/limit-search-results-to-custom-post-type#post-1671437)你可以看到如何做到这一点的例子。只需将其修改为您的需求,您就可以做好准备:) –