Home › Forums › ACF PRO › Relationship query breaking search.php results › Reply To: Relationship query breaking search.php results
It’s very simple standard search.php – i’m fairly certain it isn’t templating related but have a look – it’s built off of Bones WP :
<?php get_header('search'); ?>
<div id="content">
<div id="inner-content" class="wrap cf">
<main id="main" class="cf" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog">
<!-- USER PANELS -->
<article class="cf" role="article" itemscope itemtype="http://schema.org/BlogPosting">
<section class="middlecontent cf" itemprop="articleBody">
<h3>Results:</h3>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
$posts = get_field('author_selector');
if( $posts ): ?>
<?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php endforeach; ?>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif; ?>
<figure class="effect-marley m-all t-1of3 d-1of3">
<div class="thumbwrap">
<?php if ( get_the_post_thumbnail($post_id) != '' ) {
echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
the_post_thumbnail('sterling-largethumb');
echo '</a>';
} else {
echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
echo '<div class="fillthumb" style="background-image:url(';
echo catch_that_image();
echo ');"></div>';
echo '</a>';
} ?>
</div>
<figcaption>
<h2><?php the_title(); ?></h2>
<p><?php the_excerpt(); ?></p>
<a href="<?php the_permalink(); ?>">View more</a>
</figcaption>
</figure>
<?php endwhile; ?>
<?php wpex_pagination(); ?>
<?php else : ?>
<?php endif; ?>
</section>
</article>
</main>
</div>
</div>
<?php get_template_part( 'partials/socialmedia', '' ); ?>
<?php get_footer(); ?>
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.