wordpress API for android app

Yes, WP REST API supports user authentication. With this plugin you can use OAuth authentication, application passwords, or basic authentication. Read this. Here you’ll find complete documentation. For JSON API there is a plugin called JSON API Auth. Here you’ll get it. By using it you can implement authentication with JSON API. And yes, as … Read more

Create filtered list of posts using JSON data

First, you must allow your custom field be queried from the REST API. Let’s start simple with an example from 1fix.io: function my_allow_meta_query( $valid_vars ) { $valid_vars = array_merge( $valid_vars, array( ‘meta_key’, ‘meta_value’ ) ); return $valid_vars; } add_filter( ‘rest_query_vars’, ‘my_allow_meta_query’ ); So, asuming your field name is called “favorite_animal”, for this example, you can … Read more

Full-Ajax Theme: parseJSON error while building a JSON object from a WordPress custom template

Replacing all the specific the_content() functions, or the_ID… etc by the getters equivalent seems to fix the problem. Here the solution: <?php $o = array(); $o[ ‘title’ ] = wp_title( ‘|’, false, ‘right’ ); $o[ ‘type’ ] = ‘single-project’; //ob_start(); $article=”<div id=”container” class=”content-area project-content”>”; $article .= ‘<main id=”main” class=”site-main” role=”main”>’; while (have_posts()) : the_post(); $article … Read more

How to encode post content as JSON?

To output JSON always the function json_encode( $string ). The function is not available on all hosts. Don’t worry, WordPress offers a fallback in wp-includes/compat.php. That’s a wrapper for class Services_JSON::encodeUnsafe() (see wp-includes/class-json.php). If you take a look at the source you’ll see: It’s not a trivial job to encode a string. 🙂 There is … Read more

utf8 encoding in json rest api

The problem is here: ‘excerpt’ => wp_json_encode($post->post_excerpt), That array will get passed through wp_json_encode by the REST API, so it gets double encoded, so remove the wp_json_encode here, and it’ll work out fine, it’s just encoding, it’s not the literal human readable value. E.g. put it in your browsers dev console and output the result, … Read more

Changing the entire control choices using wp.customize with JavaScript

You’re close. You just need to replace changeTheChoices() with set() as this is a method on wp.customize.Setting. See the following which also refactors a bit: wp.customize( ‘setting_category’, ‘setting_font’, function( categorySetting, fontSetting ) { categorySetting.bind( function( category ) { var newChoices = {}; // get new data from JSON using ‘category’ and populate the ‘newChoices’ fontSetting.set( … Read more