admin管理员组文章数量:1122832
I have a forum system where I created a custom post type, and I would like to have a search system for the topics, but I do not know what the structure would be, for example, how the file will be and the search form action.
I have a forum system where I created a custom post type, and I would like to have a search system for the topics, but I do not know what the structure would be, for example, how the file will be and the search form action.
Share Improve this question asked Aug 8, 2017 at 23:07 Carlos StevanatoCarlos Stevanato 51 silver badge4 bronze badges2 Answers
Reset to default 0I found an answer here, but it is treated as if I wanted a custom post type of a theme, in my case I created it as a Plugin, someone would have a light there of how I can create a search within a custom post type but that is Inside a plugin?
How to create a custom search for custom post type?
You should try this in your search
global $query_string;
wp_parse_str($query_string, $search_query);
//add post type.
$post_type = array('post_type'=>'your-custom-post-type');
$combine_search = array_merge($search_query,$post_type);
$search = new WP_Query($combine_search);
本文标签: Creating a search results page from a custom post type in a plugin
版权声明:本文标题:Creating a search results page from a custom post type in a plugin? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736282709a1926730.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论