Version 0.3.2 of Efficient Related Posts was just released. Due to popular demand, it now has a shortcode to add add the list of posts anywhere shortcodes are supported in the loop. The readme was also updated to answer some of the common usage questions and to explain how to use the new shortcode.
The best place to find information is on the Efficient Related Posts page which is updated regularly. However, here are some of the new FAQs.
How can I add a list of related posts to my posts?
You can configure Efficient Related Posts to add related posts automatically in Settings -> Related Posts. Alternatively you can use the shortcode [relatedPosts] or the helper functions
wp_related_posts() in your theme files.
How exactly do you use the [relatedPosts] shortcode?
To use the default settings (from Settings -> Related Posts) you just need to add
[relatedPosts] to your post or page where you want to list to be. You can also add some attributes to it such as num_to_display (Number of related posts to display), no_rp_text (Text to display if there are no related posts), and title (Title for related posts list, empty for none) like this:
[relatedPosts title="Most Related Post" num_to_display="1"]
[relatedPosts num_to_display="1" no_rp_text="No Related Posts Found"]
[relatedPosts title="Try these related posts:" num_to_display="3" no_rp_text="No Related Posts Found"]
How do the theme helper functions work?
You can use
wp_related_posts() to display a list of related posts in your theme. They need to be used in “the loop” and the only difference is that
wp_get_related_posts() returns the list and wp_related_posts() echos the list. You can also pass an associative array of arguments to it such as num_to_display (Number of related posts to display), no_rp_text (Text to display if there are no related posts), and title (Title for related posts list, empty for none) like this:
wp_related_posts(array('title'=>'Most Related Post', 'num_to_display'=>1))
echo wp_get_related_posts(array('num_to_display'=>1, 'no_rp_text'=>'No Related Posts Found'))
wp_related_posts(array('title'=>'Most Related Post', 'num_to_display'=>3, 'no_rp_text'=>'No Related Posts Found'))
Showing related content to your users is important. I don’t think there’s anyone disputing that (at least not that I’m listening to). The real question is “how?” How can you show your user good related content without adding a ton of extra work for yourself? This is where related posts plugins come into play.
There are a lot of options out there. So many that it’s quite time consuming to try them all until you find one that suits you. Two of my favorites are WordPress Related Posts and Yet Another Related Posts Plugin (YARPP). Yarpp gives you more control over how matches are made, but for that very reason it’s also less efficient. Joost de Valk referred to it as a “heavy plugin” in his article on Optimizing WordPress database performance, and it definitely is. WordPress Related Posts is far more efficient, but offers you a little less control over how matches are made. Unfortunately they share the same problem.
So what is this problem? They all find matches to a post in the front end rather than the back end. They do it when a user views a specific post, rather than when a post is created or modified. On a brand new site I launched, which has only 7 posts, we’ve received roughly 2000 pageviews. That’s pretty low, but lets take a look at it. About 700 of those visits were to the home page and about 1300 were to single post pages. If you only show related posts on single post pages (which is how we currently do it) then the related posts plugin has been run over 1300 times for only 7 posts, which is roughly 185 times per post! If I were to show related posts for each post on the front page then it would have run another 4000 times (which is a conservative estimate), bringing it to 757 times per post. If you think this seems excessive, lets take a look at the stats for Web Developer News. It has had over 13,500 page views in the last 30 days. About 750 were to the home page, about 140 were to other static pages, roughly 550 were to tag pages, and another 250 were to miscellaneous pages such as search pages. That leaves 11,810 visits to single post pages and 21 posts during that same time. That’s about 562 times per post! If I added related posts to the home page, tag pages, and search pages it would need to be run roughly another 15,000 or 1,276 times per post.
WordCamp San Diego 2012
- Acholi Beads (1)
- apache (1)
- BuddyPress (2)
- Community (3)
- CSS (1)
- General (6)
- News (1)
- Open Source (3)
- PHP (5)
- PrototypeJS (3)
- Script.aculo.us (1)
- Uncategorized (5)
- Web Design (11)
- Wordpress (19)
- wordpress development (7)
- WordPress News (11)
- WordPress Plugin Updates (11)
- WordPress Plugins (2)
- WordPress SEO (1)
- WordPress Themes (2)
- WordPress Widgets (2)
Recent Forum Posts
Unchecking "Include retweets" option will not stick
posted in forum Twitter Widget Pro by Katie on September 26, 2011 at 2:52 pm
Tweet update problem
posted in forum Twitter Widget Pro by JayFromBKK on September 24, 2011 at 6:54 am
Tweets not updating
posted in forum Twitter Widget Pro by SgtMac on September 21, 2011 at 11:04 am
Grey follow button
posted in forum Twitter Widget Pro by firstname.lastname@example.org on September 21, 2011 at 4:53 am
Feature Request: Code Location
posted in forum Google Analytics by Katie on September 19, 2011 at 6:29 pm
- Unchecking "Include retweets" option will not stick