How to share repeated fields across multiple pages?

The ACF functions accept a second argument which is the ID of the page you wish to retrieve the fields from. See the code examples in documentation. $page_id = 120; if( get_field( ‘treatments’, $page_id ) ): while( has_sub_field( ‘treatments’, $page_id ) ): // the_sub_field and get_sub_field don’t need a post id parameter the_sub_field(‘image’ ); the_sub_field(‘description’ … Read more

Changing a specific value inside a complex repeater/flexible content field (ACF)

Answering my own question again. šŸ˜› I finally found this Gist that lets me get and set array variables via dot notation: https://gist.github.com/elfet/4713488 So I included the DotNotation class and now my code looks like this (skipping all sorts of error checking here) : $fieldmap_string = ‘key1.key2.key3.etc’; $current_page_content = get_field(‘page_content’, $source_post_id); $parsed_current_content = new DotNotation($current_page_content); … Read more

My get_terms not working for custom fields

The issue is with ACF as discussed here along with a solution: https://support.advancedcustomfields.com/forums/topic/how-to-use-wp-term-meta-on-acf-the-easy-way/ Courtesy of various posters there, the code I added to mu-plugins is: function acf_update_term_meta($value, $post_id, $field) { $object = get_queried_object(); $term_id = intval(filter_var($post_id, FILTER_SANITIZE_NUMBER_INT)); if (!isset($object->taxonomy) || !isset($object->term_id) || $term_id != $object->term_id) { // the current object is not a term return … Read more

Gutenberg on an ACF options page

Create a page named as your archive, add blocks there. In archive-name.php please add: <?php get_header(); $page_id = get_post( 57 ); $page = apply_filters( ‘the_content’, $page->post_content ); echo $page; ?> <?php get_footer(); Replace ’57’ with your page ID. Now you can manage content of archive page directly from Pages.

Post edit – Media Library – Only get images from current post

This will lock uploads to ā€œUploaded to this postā€ and will not show ā€œAll media itemsā€ or other options in WordPress media panels. Add this code to your function.php file add_action( ‘admin_footer-post-new.php’, ‘firmasite_mediapanel_lock_uploaded’ ); add_action( ‘admin_footer-post.php’, ‘firmasite_mediapanel_lock_uploaded’ ); function firmasite_mediapanel_lock_uploaded() { ?> <script type=”text/javascript”> jQuery(document).on(“DOMNodeInserted”, function(){ // Lock uploads to “Uploaded to this post” jQuery(‘select.attachment-filters … Read more