WordPress API – count posts

Assuming you are using Linux or OS X, the easiest way is probably to use wp-cli (if present in your WordPress installation) to return a list of all posts: wp-cli post list Then pipe it to the word count tool to get the number of lines: wc -l Finally, deduct one to take care of … Read more

curl POST work with user meta but not the custom user meta

arguments get_callback and update_callback receive different arguments. try this exemple which works for a field user_continent add_action(“rest_api_init”, function () { register_rest_field( “user” , “user_continent” , [ “get_callback” => function ($user, $field_name, $request, $object_type) { return get_user_meta($user[“id”], $field_name, TRUE); }, “update_callback” => function ($value, $user, $field_name, $request, $object_type) { update_user_meta($user->ID, $field_name, $value); }, ] ); });

Developing Themes with React/Angular

First of all like Fayaz had said questions with multiple questions are not the best way to ask something on this platform. Ok, let me try to answer your questions. (Disclaimer: I’m not an react expert. So please don`t hang me if i tell something stupid.) Question 1: No you need not Node.js but npm … 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

Passing variables to new page

Edit: OK, I get what you’re trying to do a little better. This should help get you there. Cache the data that you are going to want. You’ll go over your API limit quickly if you query Yelp on every page load – not to mention slowing your site down terribly. function yelplist() { $pizza_joints … Read more

“rest_no_route” – Debug error

You should not GET on a POST only rest callback. The code below creates a POST call only register_rest_route(‘miningRigs/v1’, ‘createRig’, array( ‘methods’ => WP_REST_SERVER::CREATABLE, ‘callback’ => ‘createMiningRig’, )); Check http://localhost/wordpress-site/wp-json/miningRigs/v1 which shows you can only POST on createRig I just copy/paste you code + added the https://pressupinc.com/blog/2013/07/minimum-viable-wordpress-plugin/ then enabled the plugin on 4.9.5 and it … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)