68

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


55

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): ...


25

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']-&...


13

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_featured_image_json( $data, $post, $context ) { $featured_image_id = $data->data['featured_media']; // ...


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

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


5

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/


5

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


5

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/


5

To anyone who might still be hitting this problem, here's a checklist: Make sure you are authenticated AND your user has the list_users capability. Example: When adding a custom role, I make sure to add the list_users capability. The user should also be logged in (what authenticated means) when making the request. By default, only users who have ...


4

@Liren answer works well. However few beginners may not able to adjust the route. Here is the code that works well with WordPress Rest API v2 with minimum modification. Replace your menu name only in wp_get_nav_menu_items() function. If menu name and slug does not work (Return false), use Menu ID (visible in Dashboard while editing that Menu). function ...


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

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 ...


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

Thanks to stackoverflow user Milap ! You can get all users even they have not created any post, for that you need to modify rest-api plugin. Open wp-content/plugins/rest-api/lib/endpoints/class-wp-rest-users-controller.php file, you will find below code on line number 106, if ( ! current_user_can( 'list_users' ) ) { $prepared_args['has_published_posts'...


3

Take a look at a plugin called Better REST API Featured Image. It adds the featured image URL to the original API response.


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

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

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

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

A quick search through the WP-API source revealed where validate_callback is being used: wp-api/lib/infrastructure/class-wp-rest-request.php $valid_check = call_user_func( $arg['validate_callback'], $param, $this, $key ); In this case, $this is an instance of WP_Rest_Request - so there's one. Now, for sanitize_callback: $this->params[ $type ][ $key ] =...


2

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


2

I think it is better that you switch to the current beta, version 2, publish on github. This version is much better in possibilities and performance. In this version it is possible that you get a result for the search term, Iike GET /wp-json/wp/v2/posts?s=awesome.


2

I assume you're using this plugin? From the docs it seems you can use standard query arguments, so try: /api/get_posts/?job_loc=yangon&page=10&count=5


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 ...


2

You are using name in your terms. In default, try to use the existing term id ( in your case, cat ID and tag ID ). If you see https://plugins.trac.wordpress.org/browser/rest-api/trunk/lib/endpoints/class-wp-rest-posts-controller.php#L918 they will handle your term with sanitize them into non-negative integer using absint. I hope this help. Here example ...


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