wp-api

Nuxt Generate Dynamic Routes Path

五迷三道 提交于 2020-01-23 03:02:07
问题 I'm creating a site with wp-api. All my pages are inside: - pages -- _slug If my page slug are site.com/about - pages -- about Nuxt will generate html like this. But... If my path are site.com/company/about Can I create this routes? PS: I'm using wordpress api for that. So if my pages has parent pages, the path are: site.com/parent/child 回答1: You can use the routes key in nuxt.config.js to do this. The docs are here: https://nuxtjs.org/api/configuration-generate/#routes In a nutshell, you can

WP Rest API + AngularJS : How to grab Featured Image for display on page?

老子叫甜甜 提交于 2019-12-19 17:47:10
问题 I am accessing Wordpress data through an HTTP REST API plugin (this wordpress plugin: http://v2.wp-api.org/). I know how to grab my post title, but how do I display the featured image associated with that post using this plugin? My test shows the post title and the featured image ID, but I am unsure how to display the actual image. Test Example. Here's my code: <div ng-app="myApp"> <div ng-controller="Ctrl"> <div ng-repeat="post in posts | limitTo: 1"> <h2 ng-bind-html="post.title.rendered"><

Post request to custom end point

只愿长相守 提交于 2019-12-12 04:27:55
问题 I wish to make a post request to a remote site but so that it updates remote site with data from database. I succeeded in getting the data using get request from database of current site but am unable to create a callback function for the post request. This is my code function register_custom_route(){ register_rest_route( 'silentblast-dashboard/v1', '/getsetting/(?P<id>\d+)', array( array( 'methods' => 'GET', 'callback' => 'retrieve_settings_data', ), array( 'methods' => 'POST', 'callback' =>

WordPress WP REST API limiting requests by domain

谁说胖子不能爱 提交于 2019-12-11 01:39:44
问题 This seems like it would be more obvious. I use WordPress to manage content for an external site. The WordPress content is displayed via the WP REST API and I display content with ajax and JS to this remote site. (e.g. https://example.com//wp-json/wp/v2/pages/23). Everything is on SSL and it all works great. How can I simply make it so this ajax GET request is only allowed from a certain domain - the remote site? The WP API is only used to display data. 回答1: I just had look at the php server

Disable default routes of WP REST API

♀尐吖头ヾ 提交于 2019-12-08 15:33:32
问题 I need to disable default routes of WP REST API and add custom routes. I found this question which helps me to find following answer. remove_action('rest_api_init', 'create_initial_rest_routes', 99); However this will also remove any custom content type routes. So instead you may choose to use: add_filter('rest_endpoints', function($endpoints) { if ( isset( $endpoints['/wp/v2/users'] ) ) { unset( $endpoints['/wp/v2/users'] ); } // etc }); But from that way I need to know all the default

WordPress REST API - Allow anyone to POST

白昼怎懂夜的黑 提交于 2019-12-07 05:02:14
问题 I am building an application on WordPress that requires a simple front end form where anyone can submit information that needs to be saved in the database. I am attempting to handle this through the REST API. (Due to the nature of the application, there can not be any redirection of the page when this information is submitted.) I have no problem setting up the REST API (v2) so that I can submit a post. It works great when I am logged into WordPress. When I try to fill out the form when I am

WordPress REST API - Allow anyone to POST

半城伤御伤魂 提交于 2019-12-05 10:00:33
I am building an application on WordPress that requires a simple front end form where anyone can submit information that needs to be saved in the database. I am attempting to handle this through the REST API. (Due to the nature of the application, there can not be any redirection of the page when this information is submitted.) I have no problem setting up the REST API (v2) so that I can submit a post. It works great when I am logged into WordPress. When I try to fill out the form when I am not logged in to WordPress, I receive an error. Failed to load resource: the server responded with a

Rendering external HTML/React components dynamically in React

梦想的初衷 提交于 2019-12-04 10:38:15
问题 Is it possible to take HTML/JSX content from an external source and render it in dynamically in React? In our case we want to take content from the Wordpress API and render it on both the client and the server (we're using NextJS) So, the Wordpress API returns a JSON response which includes a content property which is a string of HTML/JSX. the content would look something like this. { content: "<div><Slider imageCount="5" galleryID="1"></Slider><span>This is an image gallery</span></div>" }

Make WordPress WP-API faster by not loading theme and plugins

若如初见. 提交于 2019-12-03 13:46:32
问题 I would like to make requests to the WordPress API much faster. My API is implemented in a plugin (using register_rest_route to register my routes). However, since this is a plugin, everything is loaded with it (the child-theme and the theme) and basically a query to this API is taking half a second because of all this useless parts loaded. Doesn't WordPress API can be used in another way? Since most plugin making use of the WP-API doesn't need any other plugins to be loaded, even less a

Rendering external HTML/React components dynamically in React

别来无恙 提交于 2019-12-03 06:25:08
Is it possible to take HTML/JSX content from an external source and render it in dynamically in React? In our case we want to take content from the Wordpress API and render it on both the client and the server (we're using NextJS) So, the Wordpress API returns a JSON response which includes a content property which is a string of HTML/JSX. the content would look something like this. { content: "<div><Slider imageCount="5" galleryID="1"></Slider><span>This is an image gallery</span></div>" } So, as you can see it would be a mix of HTML and React components/JSX, represented as a string I would