Home › Forums › ACF PRO › Query relationship field in repeater › Reply To: Query relationship field in repeater
<?php
/**
* The Template for displaying all single posts
*
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/
get_header(); ?>
<?php
// custom filter to replace '=' with 'LIKE'
function my_posts_where( $where )
{
$where = str_replace("meta_key = 'list-wines_%_item-wine'", "meta_key LIKE 'list-wines_%_item-wine'", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
// args
$args = array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'list-wines_%_item-wine',
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE'
)
)
);
// get results
$the_query = new WP_Query( $args );
// The Loop
?>
<?php
if( $the_query->have_posts() ): ?>
<ul>
<?php while ( $the_query->have_posts() ) : $the_query->the_post();
$parent_id = get_the_ID();
?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_ID(); the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
I got the snippet from the forums…I need to get the time code for the item-wine to, not just the title. Could anyone give me a hint, please
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.