-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create custom endpoints #29
Comments
Did you manage to add a custom end-point? We need it to add custom post types to WP |
I think we need this #20 |
Yes it will be very interesting. |
Hello. Go into /vendor/vnn/wordpress-rest-api/src/Endpoints and copy "Posts" class to your main app directory and rename the class to CustomPostType and update namespace appropriately. Then when you call, you'll need to do it slightly different.. So in your "GetWPApiData" class (for example) .. in a method you need to get custom endpoint data, include your class CustomPostType in the "use" area, make sure it implements "AbstractWpEndpoint" ..
Then initiate
Works great, don't have to fork or override private properties. |
Lovely - much better than hacking away in the package, then losing changes on updating... thank you! |
Any ideas why the PR was not merged? it seems like a reasonable feature. @zack-carlson could you add the feature to the readme? something like this: https://wprestclient.readthedocs.io/en/latest/extending/api-prefix/ |
@angelxmoreno I'm not sure the approach is what the maintainer wished for, but would be happy to copy the comment / explanation
|
That's cool @zack-carlson BTW, I ended up creating my own, WPRestClient because there was no license usage. The docs I linked were from my lib. I just wanted to promote the contribution of this lib since it served as an inspiration for creating |
I'm trying to create my custom end point but it looks like the endpoints are hardcoded to be classess form the
Vnn\WpApiClient\Endpoint
namespace;What's the easiest way to define a custom endpoint?
The text was updated successfully, but these errors were encountered: