在 WordPress 中搜索自定义分类法

发布于 2024-09-05 15:20:11 字数 66 浏览 9 评论 0 原文

想知道是否有任何插件/黑客可用于在 WordPress 中搜索自定义分类法?

任何想法的指导都会很棒。

Want to know is there any plugin/hack available for searching custom taxonomies in wordpress?

Directions for any idea will be great.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

薄荷梦 2024-09-12 15:20:11

这个怎么样?

function search_by_tax_filter(&$query)
{
    if ($query->is_search)
        $query->set('taxonomy', 'taxonomy_name');
}
add_action('parse_query', 'search_by_tax_filter');

How about this?

function search_by_tax_filter(&$query)
{
    if ($query->is_search)
        $query->set('taxonomy', 'taxonomy_name');
}
add_action('parse_query', 'search_by_tax_filter');
殊姿 2024-09-12 15:20:11

棘手的业务...这将帮助您开始,这会查询前五个标签(分类:post_tag)...

// query the top five tags
$sql = '
    SELECT wt.term_id ti,wt.name, wtt.count tc,wtr.term_taxonomy_id tti, wtr.object_id oi 
    FROM wp_terms wt 
    INNER JOIN wp_term_taxonomy wtt ON wt.term_id = wtt.term_id 
    INNER JOIN wp_term_relationships wtr ON wtr.term_taxonomy_id = wtt.term_taxonomy_id 
    LEFT JOIN wp_posts wp ON wp.ID = wtr.object_id 
    WHERE taxonomy = \'post_tag\' 
    GROUP BY name 
    ORDER BY count DESC LIMIT 0 , 5 
'; 

Tricky business... This will get you started, this queries the top five tags (taxonomy: post_tag)...

// query the top five tags
$sql = '
    SELECT wt.term_id ti,wt.name, wtt.count tc,wtr.term_taxonomy_id tti, wtr.object_id oi 
    FROM wp_terms wt 
    INNER JOIN wp_term_taxonomy wtt ON wt.term_id = wtt.term_id 
    INNER JOIN wp_term_relationships wtr ON wtr.term_taxonomy_id = wtt.term_taxonomy_id 
    LEFT JOIN wp_posts wp ON wp.ID = wtr.object_id 
    WHERE taxonomy = \'post_tag\' 
    GROUP BY name 
    ORDER BY count DESC LIMIT 0 , 5 
'; 
凉城凉梦凉人心 2024-09-12 15:20:11

我最近开发了一个插件,它通过前端表单(带有下拉菜单和可选的文本输入)提供自定义分类过滤:

高级自定义帖子搜索

它运行自己的结果页面,并不直接与默认的 search.php 绑定,但它仍然非常灵活,允许您覆盖插件页面在你的主题中。

I've recently developed a plugin that provides custom taxonomy filtering through front-end forms (with dropdowns and an optional text input):

Advanced Custom Post Search

It runs off of its own results page and doesn't directly tie in with the default search.php, nevertheless its still very flexible and allows you to override the plugin pages in your theme.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文