Support

Account

Forum Replies Created

  • Here’s my situation. What do we have:
    Custom post type “items” which has the following field group “Item” with the one image type field. It should returns to array.
    Also the current user has a group of fields “User dictionaries”.
    My code is:

    $args = array(
    'posts_per_page' => '-1',
    'post_type' => 'items',
    );
    $myitems = new WP_Query( $args );
    if ( $myitems->have_posts() ) :
    	while ( $myitems->have_posts() ) :
    		$myitems->the_post();
    		$image = ( get_field( 'image' ) ) ? get_field( 'image' ) : false;
    		$dic = get_field( 'dictionaries', 'user_' . get_current_user_id() );
    		//code...
    	endwhile;
    endif;
    wp_reset_postdata();

    In this case get_field for $image returns an array as it should be and get_field for $dic returns an array of the repeater field dictionaries of current user as it should be.

    But my goal is to get on the archive page a certain kind of items.
    For this I use the hook “posts_where” for modified request.

    My code:

    global $wpdb;
    add_filter( 'posts_where' , 'my_where' );
    function my_where( $where ){
    	$where .= " AND wp_posts.post_title LIKE 'b%'";
    	return $where;
    }

    All items are returned correctly. But get_field for $image now returns the ID of image and get_field for $dic now returns the digital value of the number of fields of the repeater.

    Json file of the field groups is attached.

Viewing 1 post (of 1 total)