Get ID of current taxonomy in register_rest_field

The get_callback part is generated within the WP_REST_Controller::add_additional_fields_to_object() method with: $object[ $field_name ] = call_user_func( $field_options[‘get_callback’], $object, $field_name, $request, $this->get_object_type() ); That means the callback has four input arguments: ‘get_callback’ => function ( $object, $field_name, $request, $object_type ) { // … } and for the requested category object, we can get the term id with: … Read more

Query the REST API for a Tag by slug

I was looking at this before… Here is what I found (about 7 months old from today 3/21/2018.) The “correct” way to do this with the REST API is to get the IDs of each of those tags, then make the request using the ?tags= parameter: assuming “clicks” has ID 1, and “passes” has ID … Read more

How to update custom meta fields with rest api?

I Resolved: function job_listings_to_api( $args, $post_type ) { if ( ‘job_listing’ === $post_type ) { $args[‘show_in_rest’] = true; } return $args; } add_filter( ‘register_post_type_args’, ‘job_listings_to_api’, 10, 2 ); add_action( ‘rest_api_init’, ‘create_api_posts_meta_field’ ); function create_api_posts_meta_field() { register_rest_field( ‘job_listing’, ‘_date-start’, array( ‘get_callback’ => ‘get_post_meta_for_api’, ‘update_callback’ => ‘update_post_meta_for_api’, ) ); } function get_post_meta_for_api( $object, $field_name, $request ) { … Read more

WordPress REST get all items without a taxonomy assigned

I was able to solve the problem by adding a custom route. Although i had to do the same process in php by first querying all available terms of the type and then exclude them from the query. $available_terms = array_map( function ( $term ) { return $term->term_id; }, get_terms( ‘lagerboxen_kategorie’ ) ); return get_posts( … Read more

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