blog.humaneguitarist.org



« | »

tweaking Efficient Related Posts, a WordPress plugin

There are so many plugins for WordPress that it's easy to get carried away and install more than necessary. I hope I've avoided that. I try to limit myself to plugins that can really improve the reader's experience.

The other day, I installed Efficient Related Posts (0.3.6). It's a great tool to generate a list of hopefully related posts on my blog. There should even be some listed below this post.

;)

Under the settings, you can alter what the header says and even have it auto-generate related posts for every blog post. For example, I changed the header "Related Posts" to "Related Content".

But one thing I didn't see the settings offer is a way to hide that header in cases where no related content was generated.

In other words, when no related content was generated it was displaying something like "Related Content: no related posts found." I don't want people to see that so I tweaked the code in the main plugin script using WordPress' plugin editor.

Here's the code below. It's only a minor change for the "if" block that starts at around line 307.

if ( !empty($settings['title']) && !empty($relatedPosts)) {
	$output = "--------------<h4 class='related_post_title'>{$settings['title']}</h4>{$output}";
	/* Nitin Arora modified the code above on 20101219 to display differently.
	By adding the "&& !empty($relatedPosts)" condition, only posts/pages with related content
	will show the related content header.
	A few "-"s were added to offset the related content header for readability.
	Also, the <h4> tag was originally an <h3>. */
}

	
--------------

Related Content:

Posted by on December 20, 2010.

Tags: , , ,

Categories: news, technophilia

2 Responses

  1. Thanks for this article, I had pretty much the same question (although 0.3.8 should now have an "empty" feature). Now I just need to figure out http://xavisys.com/support/forum/efficient-related-posts/wordpress-3-1-appears-to-break-efficient-related-posts/ & how to tweak ERP to find related posts by category and not only by tag … :)

    by Gwyneth Llewelyn on Aug 17, 2011 at 9:12 am

  2. Thanks. I like the idea of tweaking ERP to take “category” as a consideration.
    You’re blog is really cool, BTW.

    by nitin on Aug 17, 2011 at 6:19 pm

Leave a Reply

*

« | »




Recent Posts


Pages



Switch to our desktop site