Build on same WordPress or different install?

I’ve decided that I will do this new function as a custom post type in the same installation as the college website. I will find another project to learn and use WP Rest API. It’s an overkill to use WP Rest API on this project. I also realize that Our Team content is really part … Read more

Rest API Custom Endpoint with space character

You can do this like this: function get_custom_search_callback($request) { //$parameters = $request->get_params(); $response = urldecode($request->get_param(‘search’)); return rest_ensure_response($response); } add_action(‘rest_api_init’, ‘add_custom_users_api’); function add_custom_users_api(){ register_rest_route(‘namespace/v1’, ‘custom-search/(?P<search>([a-zA-Z]|%20)+)’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘get_custom_search_callback’ ) ); } Note two things: you have to add %20 to the matched character set you have to urldecode() the search variable value … 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

Wp Rest Api Custom Endpoint for page subpages

It works.. function list_subpages() { $data = array(); $request = array(); $id = 151; $subpages = get_pages( array( ‘child_of’ => $id, ‘sort_column’ => ‘menu_order’ ) ); if ( empty( $subpages ) ) { return null; } foreach ($subpages as $p) { $data[‘id’] = $p->ID; $data[‘title’] = $p->post_title; $data[‘img’] = wp_get_attachment_url( get_post_thumbnail_id($p->ID) ); $request[] = $data; … Read more

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