ACF Create Array of All Woocommerce Product IDs with a Checkbox ticked
ACF Create Array of All Woocommerce Product IDs with a Checkbox ticked
ACF Create Array of All Woocommerce Product IDs with a Checkbox ticked
I think you may check the Advanced Configuration of your CPT in ACF settings. There is an option to disable the View button in tab URLs called Publicly Queryable if it’s disabled. Publicly Queryable: disable Publicly Queryable: enable
Based on https://stackoverflow.com/questions/42011047/wordpress-query-by-acf-relationship-field, I was able to fix this by changing the ‘compare’ => ‘IN’ to ‘compare’ => ‘LIKE’. So the resultant code looks like this: $new_query_args = [ ‘meta_query’ => [ [ ‘key’ => ‘af_author’, ‘value’ => get_the_ID(), ‘compare’ => ‘LIKE’, ] ] ]; $query_args = array_merge( $query_args, $new_query_args ); I’m not exactly sure … Read more
According to ACF documentation, a foreach loop is to be used to access the items in a Relationship field. Untested: $templates = get_field( ‘field_61318c078a746’ ); foreach ( $templates as $template ) { $template_image_id = absint( get_field( ‘Image’, $template ) ); $template_image_url=”https://example.com/fallback-image.jpg”; if ( ! empty( $template_image_id ) ) { $template_image_url = wp_get_attachment_image_url( $template_image_id, ‘large’ ); … Read more
ACF official documentation indicates it should be as simple as using have_rows() again: if ( have_rows( ‘field_1’ ) ) { while ( have_rows( ‘field_1 ‘ ) ) { the_row(); if ( have_rows( ‘field_2’ ) ) { while ( have_rows( ‘field_2’ ) ) { the_row(); $value = get_sub_field( … ); } } } } Note that … Read more
The error is indicating that a method function (get_attribute()) is attempting to be called on a variable that is set to null. This means that the $product_object variable is not populated with an instance of a class that has a method definition for get_attribute(), but rather is null. You’ll need to figure some other way … Read more
For those looking for a PHP solution. A good place to do this is in the render_callback function. One thing to keep in mind with this solution is that this only works on first load, which is good enough for the frontend, but it will not work accurately in the Gutenberg editor itself once you … Read more
You are trying to fetch a custom post – you cannot do that with ACF javascript API directly. ACF js api is to get acf fields for a post. What you need is the wp-rest-api with restAPI enabled for the ACF field that you want to query by – in your case it is ‘osm_geometry’. … Read more
The REST API endpoint “List Posts” (e.g. GET /wp/v2/posts) does not support filtering the posts by a post meta (or custom field), therefore passing post meta parameters like meta_key and meta_value will by default do nothing. But the rest_<post type>}_query filter can be used to manually add custom meta queries to the query arguments passed … Read more
I should not have been looping at all. This (not optimized) code fixes all issues and adds Difficulty. add_shortcode(‘get_run’, ‘get_run_status’); function get_run_status($atts) { $atts = shortcode_atts(array( ‘run’ => ”, ), $atts); $run_output=””; $diff_output=””; $found_day = false; $found_night = false; $run_atts = sanitize_text_field($atts[‘run’]); $run_query = get_field($run_atts); if($run_query): $run_status = $run_query[‘status’]; $run_difficulty = $run_query[‘difficulty’]; endif; foreach ($run_status … Read more