Home Forums Front-end Issues Missing fields on search results


Missing fields on search results

  • Hi,

    I got a little issue with the search results. The search form is used to only show posts.

    It shows the results, but without the custom fields.

    I use the same code to show all the posts, on the post page, and there it works fine. So I think I’m missing something.

    This is the code I’m using:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div class="col-xs-3">
    	<div class="product">
    		<div class="image">
    			<?php if(get_field('prijzen')): ?>	
    			<?php $count_blokken=0;?>
    			<?php while(has_sub_field('prijzen')):  ?>	
    			<?php if($count_blokken < 1): ?>	
    			<div class="tag"><span>vanaf</span><p>€ <?php the_sub_field('prijs'); ?></p></div>
    			<?php $count_blokken++;?>
    			<?php endif; ?>	
    			<?php endwhile; ?>
    			<?php endif; ?>
    			<?php $image = get_field('uitgelichte_afbeelding'); ?>
    			<?php if( $image ): ?>
    			<a href="<?php the_permalink(); ?>"><img alt="<?php echo $image['alt']; ?>" src="<?php echo $image['sizes']['item-image-4']; ?>"/></a>
    			<?php else: ?>	
    			<a href="<?php the_permalink(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/img/geen-afbeelding-klein.jpg" alt="Alfred verhuur - <?php the_title(); ?>"></a>
    			<?php endif; ?>
    		<div class="cont">
    			<h4><?php the_title(); ?></h4>
    			<?php if(get_field('subtitel')): ?>	
    			<span><?php the_field('subtitel'); ?></span>
    			<?php else: ?>
    			<?php endif; ?>	
    			<a class="btn orange" href="<?php the_permalink(); ?>">Reserveringsaanvraag</a>
    <?php endwhile; ?><?php endif; ?>
  • Hi @mr_marien

    Please debug your code to make sure it is running as expected and to see what data is returned by the get_field function.


  • I have fixed the bug. It had nothing to do with the ACF field plugin.
    Thanks for the quick replay though.

  • What was the fix?

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

The topic ‘Missing fields on search results’ is closed to new replies.