Home Forums General Issues Quering relationship field on other post type?


Quering relationship field on other post type?

  • Hi,

    I followed this tutorial, for quering relationship fields from one post type on an other custom post type. It works great.

    But in one case the relationship field is a subfield of a repeater field. And there it does not work. I am trying since days but don’t get it working. Is this “two direction quering” not possible for relationship fields which are subfields of a repeater field?

    This is the code which works with normal relationship fields but not for the one inside the repeater:

    <div class="entry-content">
    	$authors = get_posts(array(
    		'post_type' => 'page',
    		'meta_query' => array(
    			'key' => 'author-name', 
    			'value' => '"' . get_the_ID() . '"', 
    			'compare' => 'LIKE'		
    <?php if( $authors ): ?>
    	<?php foreach( $authors as $authors ): ?>
    	<a href="<?php echo get_permalink( $authors->ID ); ?>">
            <div class="book-cover">
    	<?php echo get_the_post_thumbnail ( $authors->ID, 'full');  ?>
    	<?php echo get_the_title( $authors->ID ); ?>
    <?php endforeach; ?>
    <?php endif; ?>
  • Did you get this to work? I had a similar problem that stumped me for days. Instead of:

    'value' => '"' . get_the_ID() . '"',

    this worked:

    'value' => get_the_ID(),

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

The topic ‘Quering relationship field on other post type?’ is closed to new replies.