ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?

New answer I now have a better understanding of the question thanks to OPs comment and have come up with the following. Not tested! global $wpdb; /** * @var string $field The flexible content field name. */ $field = ‘a_flexible_content_field’; /** * @var string $layout The flexible layout name. */ $layout=”layoutTwo”; /** * @var string … Read more

ACF: If field contain a specific value, update value in another field programatically

Did you trying something like this in a JS script? Assuming you wants to edit the service text field. jQuery(document).ready(() => { const textfield_type = document.querySelector(‘input[name=”type”]’); const textfield_service = document.querySelector(‘input[name=”service”]’); const updateField = () => { if (textfield_type.getAttribute(‘value’) === ‘Houses’ && textfield_service.getAttribute(‘value’) === ‘2’) { textfield_service.setAttribute(‘value’, ‘NOT AVAILABLE’); } // … other rules } // … Read more

How can I add a shortcode to query Custom Post Type with ACF in WordPress?

I ultimately figured out getting a shortcode to work by reworking the code to the following: add_shortcode( ‘gr_shortcode’, ‘gr_shortcode’ ); function gr_shortcode() { $buffer=”<h3>Upcoming Titles</h3>”; $q = new WP_Query(array( ‘post_type’ => ‘game_release’, ‘posts_per_page’ => 3 )); while ($q->have_posts()) { $q->the_post(); $buffer = $buffer.get_the_title().'<br>’.$buffer.the_field(‘release_date’); } wp_reset_postdata(); return $buffer; }

How to inherit field value from parent post into in child / sub post

You can use get_post_field( ‘post_parent’ ) to get the parent ID of the current post. Whilst ACF is technically off-topic, FWIW you can pass the ID of a post as the second parameter to get_field. Combined together we can fashion a shortcode centre_field that will return any field value for the post’s parent. I’ve skipped … Read more

Add php code to wp_print_scripts?

You can use admin_footer or admin_head like below. This code only run on admin. You can also use for frontend by using wp_head or wp_footer function shapeSpace_print_scripts() { $block_yt_url=”test”; ?> <script> jQuery(document).ready(function ($) { let $yt_url = false; $(document).on( “click”, ‘#yt_run .acf-button-group’, function() { $(“.editor-post-publish-button__button”).hide(); $(“.acf-block-body div div.acf-block-fields.acf-fields div.acf-field.acf-field-text.acf-field-6260f423f1666”).css({‘height’:’inherit’,’padding’:’16px 20px’,’overflow’:’inherit’}); $(“.acf-block-body div div.acf-block-fields.acf-fields div.acf-field.acf-field-text.acf-field-6260f423f1666”).val(<?php echo … Read more