WP-API Custom Post Type json_no_route

I think what is missing in your code is the “add_action” call for your plugin init function, so all gets instantiated correctly within wp_json_server_before_serve hook. Should be something like this (note the last line): function quizno_api_init($server) { global $quizno_api_quiz; $quizno_api_quiz = new QN_API_Quiz($server); $quizno_api_quiz->register_filters(); } add_action( ‘wp_json_server_before_serve’, ‘quizno_api_init’ );

WP-API: get posts in multiple categories

Assusming you are using V1 of the WP-API, did you tried the following endpoint: http://www.example.com/wp-json/posts?filter[category_name]=pink+warm I’m looking at the code in WP_JSON_Posts class and the get_post() should be able to handle that use case. UPDATE: It seems there is a limitation with the way the query is built. Here is a potential workaround: add_filter(‘json_query_var-category_name’, function( … Read more

What WP-API authentication method should I use to interact with anonymous / not-logged visitors?

In WP REST API v2 use the permission_callback found in the Adding Custom Endpoints Docs. <?php add_action( ‘rest_api_init’, function () { register_rest_route( ‘myplugin/v2’, ‘/author/(?P<id>\d+)’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘my_awesome_func’, ‘args’ => array( ‘id’ => array( ‘validate_callback’ => ‘is_numeric’ ), ), ‘permission_callback’ => function (WP_REST_Request $request) { if ( current_user_can( ‘edit_others_posts’ ) ) { … Read more

What request is WordPress sending on theme update?

WP send pretty much… everything with update request. You can examine wp_update_themes() for logic, but data would include something like this for every theme installed: ┌──────────────────────────────────────────────────────────────────────────────┐ │ $request │ └──────────────────────────────────────────────────────────────────────────────┘ array (2) [ ‘active’ => string (6) “twentysixteen” ‘themes’ => array (16) [ ‘twentysixteen’ => array (7) [ ‘Name’ => string (14) “Twenty Sixteen” ‘Title’ … Read more

WP REST API and Access-Control-Allow-Origin

I found a .htaccess solution, but I will be happy if anyone know a working PHP solution. It’s my .htaccess with multiple domain access support and access for only GET request: # CORS Headers <ifModule mod_headers.c> SetEnvIf Origin “^http(s)?://(.+\.)?(localhost:8080|example\.com|example\.net)$” origin_is=$0 Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is Header always set Access-Control-Allow-Methods “GET” Header always set Access-Control-Allow-Headers … Read more

ng-repeat is not returning a list of posts

It looks like the tutorial you linked is using success, and you’ve changed it to then. The success method has been deprecated, so you were correct to do that. However, because then returns data a little differently from success, you’ll need to update your $scope.post variable accordingly: $scope.post = res.data; You can find a great … Read more

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