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 1
Add a comment  | 

1 Answer 1

Reset to default 0

You'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