admin管理员组文章数量:1425789
I have a custom post type, let's call it 'capability'. Each capability can have one or more tags.
I have a searchbox on the frontend that the user can type into to search for all capabilities that have the specified tag. Then all the capabilities that have that tag will render on the frontend.
Could anybody help me and and tell me how I can do this? I am not the most technical person.
I have a custom post type, let's call it 'capability'. Each capability can have one or more tags.
I have a searchbox on the frontend that the user can type into to search for all capabilities that have the specified tag. Then all the capabilities that have that tag will render on the frontend.
Could anybody help me and and tell me how I can do this? I am not the most technical person.
Share Improve this question asked Jun 6, 2019 at 9:53 LucasLucas 11 Answer
Reset to default 0You'll need to expose both the Custom Post Type (CPT) and the taxonomy you are attaching to that CPT that you'd like access to. This is a great article that helped me the first time I used it.
https://developer.wordpress/rest-api/extending-the-rest-api/adding-rest-api-support-for-custom-content-types/
If you are trying to expose the CPT and the Taxonomy to search, it's something similar when you are registering those two. The arguments for both should have public
to true and or exclude_from_search
to false
https://codex.wordpress/Function_Reference/register_post_type#Usage
https://codex.wordpress/Function_Reference/register_taxonomy#Arguments
本文标签: phpHow do I create a WP endpoint that retrieves all custom post types that have a tag
版权声明:本文标题:php - How do I create a WP endpoint that retrieves all custom post types that have a tag? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745430282a2658293.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论