WP Rest API Querying Custom Posts by ACF fields
Couldn’t get it to work. The only solution that I found was to setup a custom endpoint: http://v2.wp-api.org/extending/adding/
Couldn’t get it to work. The only solution that I found was to setup a custom endpoint: http://v2.wp-api.org/extending/adding/
The following you could add as a plugin or into your themes functions.php file. What we need to do is add a rewrite tag, custom query var, and finally replace the rewrite tag with the related post slug. Some things may vary from my code to yours. I assume chapters is the post type slug … Read more
ACF Image field takes the post->ID of the uploaded attachment. That’s what you should be passing to $request->get_param(‘image’); Here’s the code I’m using for a when a CPT is inserted via API. I’m sending a POST request with custom fields values. One of the fields is an image URL which is uploaded, attached to the … Read more
I’m guessing you haven’t exposed meta_key and meta_value to the REST API with the rest_query_vars filter, so this should do it: function my_add_meta_vars ($current_vars) { $current_vars = array_merge ($current_vars, array (‘meta_key’, ‘meta_value’)); return $current_vars; } add_filter (‘rest_query_vars’, ‘my_add_meta_vars’); Then you can refer to meta_key and meta_value in your query. Be aware that this obviously exposes … Read more
URLs made from CF Well, you can do this in many ways… One of them would be to use parse_request filter and modify it’s behavior, but it can easily mess something up. Another way would be to use save_post action and modify the posts post_name, so WordPress will work like normal, but the post_name will … Read more
Interesting exercise, a one page plugin that believes it deserves a first level menu page is wrong, IMO. I use the same technique with Jetpack. To create sub-pages in the Options Page add-on, read the documentation. The logic of this menu/sub-menu swapping is: Add multiple ACF Options Pages Create our menu first level page Remove … Read more
The thing in WP that hits a passable balance of such functionality to not so painful implementation is rewrite endpoint. They are structured a little differently from your example (i.e. /tab/2) but they are easy to implement and order of magnitude less painful than dealing with Rewrite API usually is.
Turns out it’s the helpfully titled rest_prepare_categoryfilter function prepare_restful_categories($response, $item, $request) { // Do stuff to categories } add_filter(‘rest_prepare_category’, ‘prepare_restful_categories’, 10, 3);
It is possible to save ACF data in custom tables by using a separate paid plugin called ACF Custom Database Tables. However, if your goal is just to keep the database as light as possible, meevly.com’s solution of creating your own custom metaboxes would be the lightest-weight option, versus adding two plugins just to track … Read more
It’s not in the documentation mainly because it’s an internal function, they weren’t expecting you to use or need it. have_rows() checks to see whether there is a currently active loop- if not, it creates a global with your repeater rows; if so, it picks up where you left off- then it lets you know … Read more