Home › Forums › Add-ons › Repeater Field › Repeater w/ Query › Reply To: Repeater w/ Query
I’d correct some mistake.
Here is the new code :
function my_posts_where( $pagepdf ) {
$pagepdf = str_replace("meta_key = 'pagesdupdf_$", "meta_key LIKE 'pagesdupdf_%", $pagepdf);
return $pagepdf;
}
add_filter('posts_where', 'my_posts_where');
// args
$args = array(
'numberposts' => -1,
'category' => 2,
'post_type' => 'post',
// 'meta_query' => array(
// 'key' => 'pagesdupdf_$_contenu_de_la_page',
//'value' => '"' . get_search_query() . '"',
// 'compare' =>'EXISTS')
);
// query
$the_query = new WP_Query( $args );
?>
<?php if( $the_query->have_posts() ): ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php
if( have_rows('pagesdupdf') ): ?>
<ul>
<?php while( have_rows('pagesdupdf') ): the_row();
$motcherche = get_search_query();
$motsdepage = get_sub_field('contenu_de_la_page');
foreach( $motdepage as $mot ):
if ( $motcherche == $mot) :
// vars
$image = get_sub_field('image_de_la_page');
$content = get_sub_field('contenu_de_la_page');
$link = get_sub_field('url_de_la_page');
?>
<li>
<?php if( $link ): ?>
<a href="<?php echo $link; ?>">
<?php endif; ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
<?php if( $link ): ?>
</a>
<?php endif; ?>
<?php echo $content; ?>
</li>
<?php endif; endforeach; endwhile; ?>
</ul>
<?php endif;?>
<li>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</li>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post().?>
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.