Support

Account

Forum Replies Created

  • Okay, so the $testimonials variable has found x number posts?
    Are you using the correct post ID inside the_field() and get_field()?

  • Which part is not working? Can you be more specific?

  • can you print out to the screen how many testimonials this var contains: var_dump($testimonials)

  • Grid block?
    Have you followed this setup guide?
    https://www.advancedcustomfields.com/resources/blocks/

  • $testimonial_include_image = get_field(‘testimonial_include_image’);
    $testimonial_how_many = get_field(‘testimonial_how_many’);
    $testimonial_cols = get_field(‘testimonial_cols’);
    $testimonial_author = get_field(‘testimonial_author’);
    $testimonial_content = get_field(‘testimonial_content’);
    $testimonial_image = get_field(‘testimonial_image’);

    The above code is outside the loop. the_field and get_field functions should have a post ID if not such ID is given.
    https://www.advancedcustomfields.com/resources/get_field/

  • Also this line should end with a p tag:
    <p class="swd_testimonial_content"><?php the_field('testimonial_content'); ?>

  • Could it be that there is white space in this line, between “$testimonials-> have_posts()”?
    while($testimonials-> have_posts()):

  • This would require some programming. You would want to use some WooCommerce hooks. Probably this hook “woocommerce_product_thumbnails”. But it might require others too.
    https://www.businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/
    https://docs.woocommerce.com/document/introduction-to-hooks-actions-and-filters/

  • Thank you so much @hube2! 🙂 I really appreciate your feedback and for sharing your code. Here is what I ended up using. I kept your naming convention for convenience.

    
    class MY_PROJECT_NAME_acf_filters {
    	  
    	// variable for row index
    	private $my_field_name_index = 0;
    	
    	public function __construct() {
    		// add a filter when preparing repeater
    		add_filter( 'acf/prepare_field/key=field_601cf9424f9da', array( $this, 'init_my_field_name_index' ), 10, 1 );
    		
    		add_filter( 'acf/prepare_field/key=field_6023ad409d89d', array( $this, 'filter_my_sub_field_name' ), 10, 1 );
    		
    		// add filter for ths sub field that you want to filter
    		add_filter( 'acf/prepare_field/key=field_602e8a8821e89', array( $this, 'filter_my_sub_sub_field_name' ), 10, 1 );
    	}
    	  
    	public function init_my_field_name_index( $field ) {
    		$this->my_field_name_index = 0;
    		return $field;
    	}
    	
    	public function filter_my_sub_field_name( $field ) {
    		// after filtering increment the field index
    		$this->my_field_name_index++;
    		
    		// return the field;
    		return $field;
    	}
    	  
    	public function filter_my_sub_sub_field_name( $field ) {
    		$field['choices'] = [];
    		
    		$row_index = $this->my_field_name_index - 2;
    		
    		$product_id = (int) get_user_meta( 2, 'add_products_' . $row_index . '_produkt', true );
    		
    		if ( ! empty( $product_id ) ) {
    			
    			$pewc_group = new WP_Query( [
    				'posts_per_page => ' -1,
    				'post_type' => 'pewc_group',
    				'post_parent' => $product_id,
    				'post_status' => 'publish'
    			] );
    			if ( $pewc_group->have_posts() ) {
    				while( $pewc_group->have_posts() ) { $pewc_group->the_post();
    					
    					$field['choices'] = [];
    					
    					$group_title = get_the_title();
    					$group_id = get_the_ID();
    					
    					$pewc_field = new WP_Query( [
    						'posts_per_page => ' -1,
    						'post_type' => 'pewc_field',
    						'post_parent' => get_the_ID(),
    						'post_status' => 'publish',
    						'order' => 'ASC'
    					] );
    					if ( $pewc_field->have_posts() ) {
    						while( $pewc_field->have_posts() ) { $pewc_field->the_post();
    							$field_label = get_post_meta( get_the_ID(), 'field_label', true );
    							if ( ! empty( $field_label ) ) {
    								$field['choices'][get_the_ID()] = $field_label . ' (' . get_the_ID() . ')';
    							}
    						}
    						wp_reset_postdata();
    					}
    					
    				}
    				wp_reset_postdata();
    			}
    		}
    
    		// return the field;
    		return $field;
    	}
    	  
    }
    new MY_PROJECT_NAME_acf_filters();
    
  • Thanks again John! So with your help I put this together and now it works like I want.

    add_filter( 'acf/pre_save_post' , function( $post_id ) {
    
    	// check if this is to be a new post
    	if ( $post_id != 'new' ) {
    		return $post_id;
    	}
    	
    	if ( isset( $_POST['add-to-cart'] ) && isset( $_POST['product_id'] ) ) {
    		unset( $_POST );
    	}
    
    	// return the new ID
    	return $post_id;
    
    }, 10, 1 );
    
  • Unfortunately, this did not work. The acf_form() still saves the data to the product it is embeded on.
    How can I remove the “Solved” tag?

  • Thanks John!

  • Hi again John.

    Could not get your code to work, the code you so kindly share here: https://acfextras.com/dont-query-repeaters/

    So I modified it and had to use the field keys like so:

    add_action('acf/save_post', function( $post_id ) {
    
    	$meta_key = '_book_authors';
    	$saved_values = array();
    	$authors = $_POST['acf'];
    
    	if( $authors ) {
    		foreach( $authors['field_55bf6c9024b5f'] as $key => $author ) { // field_55bf6c9024b5f: ACF field key for "book_authors" meta field
    
    			$author_id = $author['field_55dafbfa91614'];  // field_55bf6c9024b5f: ACF field key for "book_authors" meta field
    			add_post_meta( $post_id, $meta_key, $author_id, false );
    
    		}
    	}
    	
    }, 20, 1 );
    
  • Thank so much John, that’s a great answer! 🙂

  • It works by adding this script right after acf.add_action(‘ready append’, function( $el ){}

    // field_name
    	acf.fields.FIELD_NAME = acf.fields.select.extend({
    
    		type: 'FIELD_NAME',
    
    	});
  • Me too, +1 for this feature.

  • Thanks @malesandro, but I think php memory is also set 256mb according to the hosting provider. I have contacted theme about this problem again. I don’t have access to edit the phpinfo file myself.

  • I have the same problem. I have created a repeater field that is used on the_front_page, where the admin can insert google map coordinates. The admin has inserted over 200 fields of coordinates which results in a Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 32 bytes).
    Memory is set to 256MB in the wp-config.php and on server, so there should be plenty of memory.
    This issue only appears in the backend, editing the page.
    I am using ACF Version 4.3.9 and ACF repeater field Version 1.1.1.
    Is there a chance that ACF Version 5.1.5 will run better regarding this?

Viewing 18 posts - 1 through 18 (of 18 total)

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.