• I have two types of content: panels and speakers. I associate the two with each other using the ACF custom relationship field. I turned off sync for custom fields.

    My primary language is English, and the other language is Spanish. I have translations for all panels and all speakers.

    When I’m on a panels page in english, it correctly displays all of the associated speakers in their english version.

    When I’m on a panels page in spanish, the speakers do not render, but they show up in edit mode correctly.

    I’m using custom WP queries and ACF’s functions to show that content. In my custom queries, if I remove the “meta_query” aspect, content appears, but then it’s not correctly filtered.

    Anybody else have success with custom queries and/or ACF relationship fields?

    Custom Query Example:

    $panels = get_posts(array(
    	'post_type' => 'post',
    	'meta_query' => array(
    	    array(
    	        'key' => 'panel_moderator',
    	        'value' => '"' . get_the_ID(); . '"',
    	        'compare' => 'LIKE'
    	    ),
    	),
    	'orderby'    => array(
    		'panel_day' => 'ASC',
    		'panel_order' => 'ASC'
    	),
    ));
    		
    if( $panels ): 
    	foreach( $panels as $panel ): 
    		echo get_the_title( $panel->ID ); 
    	endforeach; 
    endif; 

    ACF functions Example:

    $moderators = get_field('panel_moderator');
    if( $moderators ): 
          foreach( $moderators as $moderator ):
                echo get_the_title( $moderator->ID );
          endforeach; 
    endif;
Viewing 1 replies (of 1 total)
  • Thread Starter gwydionismyhero

    (@gwydionismyhero)

    Well, I figured it out after two days of hitting my head against a wall. Had nothing to do with queries or ACF relationship field.

    I had to edit the translated panels, remove the assigned speakers, and then reassign the speakers.

    Apparently, even though the edit mode said it was associated with the translated versions of the speakers, it was still associating it with the english versions. Reassigning it made sure it was connected to the correct version of the speaker.

Viewing 1 replies (of 1 total)
  • The topic ‘Issues with custom queries with meta_query on translated pages’ is closed to new replies.