nimbrung
Member
Posted 2 months ago #
I had installing YARPP on my site and adding the template code to my single.php file and getting this error when viewing the single post page
Fatal error: Call to a member function have_posts() on a non-object in
the code i had put is ...
<?php if ($related_query->have_posts()):?>
<?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
- " rel="bookmark"><?php the_title(); ?>
<?php endwhile; ?>
<?php else: ?>
<p>No related posts.</p>
<?php endif; ?>
please any help :)
@nimbrung - adding that code to your single.php file won't work... what you need to do is simply insert related_posts() into your single.php file and then create a separate yarpp-template-....php file in that same theme folder with that YARPP template code. A full explanation is on the YARPP templating tutorial.
nimbrung
Member
Posted 2 months ago #
sorry for the double posting cause i don't know where i must put it :)
anyway thx for your help, now it's working fine ... the only problem is when YARPP doing cache on my site increasing mysql cpu load
@nimbrung. Good. As for the MySQL load, I recommend you *not* build the cache all at once but instead keep the "on the fly" option on. Then your related posts cache will be built up organically.