60

You can get it without plugins by adding _embedas param to your query /?rest_route=/wp/v2/posts&_embed /wp-json/wp/v2/posts?_embed


40

Since I don't like it myself when the top answer is "Install plugin X", here is how I solved it: Menus are currently not available in the WP Rest. So what you need to do is register your own custom endpoint and then just call that route from your application that needs it. So you would include something like this (in your functions.php, plugin, wherever): ...


16

Just add the next parmater into the function register_post_type, it can be before 'menu_position'parameter. 'show_in_rest' => true if you're using a plugin to register your posttype you can use the next code: add_action( 'init', 'add_anuncios_to_json_api', 30 ); function add_anuncios_to_json_api(){ global $wp_post_types; $wp_post_types['anuncio']-&...


10

I would NOT use the better rest API plugin. It did add featured images to the rest api but it also broke it. This is the simplest solution I was able to find that actually worked. Add the following code to your functions.php: <?php function post_fetured_image_json( $data, $post, $context ) { $featured_image_id = $data->data['...


9

It did appear that the json wasn't being cached by wp-super-cache, but we decided to take a different approach. By using the transient api, we were able to do a faux-cache on all json, and drastically reduce the taxing of the database. Then on the ajax side of things, we are caching the html that is created from this semi-cached json. Things are super speedy!...


8

I will give you a small answer to your update, doing this with the WP API. The API have the possibilities to use the WP_Query like also in core, but about the get parameters in the url. A URL to pull content from Post Status would look like this: http://example.com/wp-json/posts To pull content with WP_Query parameters you’re used to, you could do it like ...


6

Looking through the source code, this plugin maps the query variable orderby to the WP_Query argument of the same name, orderby. What this means is that you should be able to do the following: http://www.example.com/wordpress/?json=get_author_posts&author_slug=user&post_type=custom&include=title,custom_fields&custom_fields=date_value&...


6

WP Super Cache examines your WordPress site's pages for some HTML tags before it caches them. Your pages most probably don't have </html> tag (common issue), in that case, try adding something like //</html> -- that's a workaround, and WP Super Cache should then generate cached versions of your pages. Why does WP Super Cache do it like that? ...


6

There is a navigation menu plugin extension for the REST API v2: https://wordpress.org/plugins/wp-api-menus/


4

I don't know of a plugin that does it in a general way; for the most part, you'll need to build something custom for each specific API you intend to communicate with. For your purposes, the key function will be wp_remote_post(), which is a wrapper for the POST method of WP's HTTP class. (Use this instead of making manual cURL requests, because WP_Http has ...


4

To list terms of custom taxonomy in your case books we will need to create a custom controller for JSON API. Step 1: Following 2 classes should be paste in a php file stored in your theme directory (you can store the file whereever you like but then you will have to make sure you return the correct path of the file in code in Step 2). File name for this ...


4

You can add your own AJAX API for do_shortcode. Add this to a suitable location (i.e. functions.php or a plugin): add_action('wp_ajax_doshortcode', 'ajax_doshortcode'); function doshortcode() { echo do_shortcode($_POST['text']); die(); // this is required to return a proper result } And this to your Javascript: $.ajax({ url : ajaxurl, data : { ...


4

To show custom post types in version 2, you need to add 'show_in_rest' => true in the register_post_type function arguments, then your posts with that custom post type will be available at the endpoint: wp-json/wp/v2/your-custom-post-type. Source: http://scottbolinger.com/custom-post-types-wp-api-v2/


4

You need to call like below. API call:- http://78.47.177.214/blog/api/get_nonce/?json=get_nonce&controller=posts&method=create_post Responce:- {"status":"ok","controller":"posts","method":"create_post","nonce":"92f31d49b5"}


4

You can get the name of the image with this path: array_name._embedded['wp:featuredmedia']['0'].source_url


4

To create any content on a WordPress website via REST-API your must use authentication. You have two options for getting OAuth tokens, Detailed explanations in the following link: https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/


3

That's probably because the "JSON API plugin" htmlescapes your text. So if you would just display it on site it should print OK, but if you need to work with it on the backend than just use html_entity_decode()


3

SECURITY NOTE: This (and the other solutions) shouldn't be used unless you have a way to override the Content-Type: text/html header that WP Super Cache sends with the appropriate application/json value. Sending JSON as text/html will cause the browser to render it as HTML, which could potentially be an XSS vector. It looks like that needs to be done at the ...


3

I think it depends on the specifics on what your looking for, you can gain the most control by making your own route tough, the users route is more meant to list out users, not exactly search them as there is a pretty crazy amount of stuff you could be wanting to search based off of, and doing that all through parameters might get difficult. I am not saying ...


2

There is very little documentation, the link in EAMann's comment is the best I have seen. To grab plugin specific data you can use the following url and it will return XML with a lot of info. http://api.wordpress.org/plugins/info/1.0/plugin-name.xml For example: http://api.wordpress.org/plugins/info/1.0/akismet.xml


2

So far as I know, it's available to use. Your site already hits it a few times each day for plugin updates, theme updates, etc. It's not really well-documented, though ... so when you start building your code, please document what calls you're using and how you're using them in the Codex so everyone else can benefit.


2

in your themes function file add: add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 50, 50, true ); // 50 pixels wide by 50 pixels tall, crop mode ..etc - http://codex.wordpress.org/Post_Thumbnails#Setting_a_Post_Thumbnail Then in your theme index file add the following inside the has post loop: // check if the post has a Post ...


2

I think it really all depends on what the issue with limiting this information is. Do you not want this particular data to be exposed? Do you not want to iterate through so much data? Are you intending on passing this data through a $.getJSON() request? Are you passing this data to a PHP function to handle it? You can create a new controller to handle this ...


2

Try python-wordpress-xmlrpc. See documentation and GitHub repository. I haven’t tested it for myself, but it looks promising.


2

You can sort via javascript .sort() a json array. Your example string was also splitable via php, like explode() explode( '&', $your_string ); or parse_url For sorting a JSON with php use usort; do you find solutions via G* search. Also you can use json_decode(), my favorite way, and create a php array from the json object and use on of different ...


2

I had to do the same thing. I used the JSON API plugin and had to create a new controller for JSON API that read the specific data out of the tables that All-in-One created. Unfortunately there really were not the right calls in the calendar plugin to access all the data (or at least on the older version I used this for) so I had to write the whole ...


2

If you know the key of your meta field then you can use this filter: add_filter( 'json_prepare_post', function ( $data, $post, $context) { $data['myextradata'] = array( 'somekey' => get_post_meta( $post['ID'], 'abcdef', true ), ); return $data; }, 10, 3 ); Replace abcdef with the key of your meta field. Then, if you get a posts' json,...


2

More reliable will be allowing specific IP instead of domain using REMOTE_ADDR header. You can use HTTP_REFERRER header but it is not reliable. You can do it via using rest_authentication_errors filter. add_filter( 'rest_authentication_errors', 'wpse150207_filter_incoming_connections' ); function wpse150207_filter_incoming_connections( $errors ){ $...


2

You can try this to show the full post content only in the JSON API: function remove_more_wpse_96740($content) { if(get_query_var('json')){ global $post; $content = preg_replace('/<!--more(.*?)?-->/','',$post->post_content); } return $content; } add_filter('the_content', 'remove_more_wpse_96740',1); by targeting the ...


2

As @TheDeadMedic mentioned the API will exclude any meta with underscore. It's not a good idea to remove the underscore as it might break something in your code or dependencies, however you can try adding a code like this in your functions.php to unprotect the desired meta add_filter( 'is_protected_meta', 'wp692_meta_unprotect', 10, 2 ); function ...


Only top voted, non community-wiki answers of a minimum length are eligible