• I am trying to include YARP in my single.php page. This is my code:

    <div class="similar_posts">
    	<h3>Related Posts</h3>					
    
    	<?php if ($related_query->have_posts()):?>
    		<ul>
    
    		<?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
    			<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
    		<?php endwhile; ?>
    		</ul>
    
    	<?php else: ?>
    		<p>No related posts.</p>
    	<?php endif; ?>					
    
    </div>

    I am getting a “Call to a member function have_posts() on a non-object error on line 31” which refers to <?php if ($related_query->have_posts()):?>

    Where is this $related_query object declared or created? Would appreciate any help.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Yet Another Related Posts Plugin] Call to a member function have_posts() on a non-object er’ is closed to new replies.