Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/engyahmed7/wp-api-for-custom-post-type/archive/refs/heads/main.zipNo built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
Custom Post Type API REST Plugin
Description
This WordPress plugin registers REST API routes for a custom post type, allowing for CRUD operations via the WordPress REST API.
Installation
- Download the plugin files.
- Upload the plugin folder to the
/wp-content/plugins/directory. - Activate the plugin through the 'Plugins' menu in WordPress.
Usage
Once activated, the plugin will automatically register REST API routes for the custom post type. You can interact with these routes using standard REST API methods.
Endpoints
List Items
- URL:
/wp-json/{namespace}/{rest_base} - Method: GET
- Callback:
get_items - Permission Callback:
get_items_permissions_check
Create Item
- URL:
/wp-json/{namespace}/{rest_base} - Method: POST
- Callback:
create_item - Permission Callback:
create_item_permissions_check - Arguments: Defined by
get_endpoint_args_for_item_schema(true)
Get Item by ID
- URL:
/wp-json/{namespace}/{rest_base}/(?P<id>\d+) - Method: GET
- Callback:
get_item - Permission Callback:
get_item_permissions_check
Update Item by ID
- URL:
/wp-json/{namespace}/{rest_base}/(?P<id>\d+) - Method: POST
- Callback:
update_item - Permission Callback:
update_item_permissions_check - Arguments: Defined by
get_endpoint_args_for_item_schema(false)
Delete Item by ID
- URL:
/wp-json/{namespace}/{rest_base}/(?P<id>\d+) - Method: DELETE
- Callback:
delete_item - Permission Callback:
delete_item_permissions_check
Contributing
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes.
- Commit your changes (
git commit -am 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Create a new Pull Request.
License
This plugin is licensed under the MIT License.