Contextual Related Posts plugin for WordPress

Overview:

Contextual Related Posts is a powerful plugin for WordPress that allows you to display a list of related posts on your website and in your feed.

The list is based on the content of the title and/or content of the posts which makes them more relevant and more likely to be of interest to your readers. This allows you to retain visitors, reduce bounce rates and refresh old entries.

Contextual Related Posts is one of the most feature rich related posts plugins for WordPress with support for thumbnails, shortcodes, widgets, custom post types, caching and CSS styles.

Key features

  • Automatic: CRP will start displaying related posts on your site and feed automatically after the content when you activate the plugin. No need to edit template files
  • Manual install: Want more control over placement? Check the FAQ on which functions are available for manual install.
  • Widgets: Add related posts to widgetized area of your theme. Lots of options available
  • Shortcode: Use [ crp ] (no spaces) to display the posts anywhere you want in the post content
  • The algorithm: Find related posts by title and/or content of the current post
  • Caching: Related posts output is automatically cached as visitors browse through your site
  • Exclusions: Exclude posts from categories from being displayed in the list. Or you can exclude posts or pages by ID
  • Custom post types: The related posts list lets you include posts, pages, attachments or any other custom post type!
  • Thumbnail support:
    • Support for WordPress post thumbnails
    • Auto-extract the first image in your post to be displayed as a thumbnail
    • Manually enter the URL of the thumbnail via WordPress meta fields
    • Use timthumb to resize images or use your own filter function to resize post images
  • Styles: The output is wrapped in CSS classes which allows you to easily style the list. You can enter your custom CSS styles from within WordPress Admin area
  • Customisable output:
    • Display excerpts in post. You can select the length of the excerpt in words
    • Customise which HTML tags to use for displaying the output in case you don’t prefer the default list format

Requirements:

Installing

  1. Download Contextual Related Posts
  2. Extract the contents of contextual-related-posts.zip to wp-content/plugins/ folder. You should get a folder called contextual-related-posts
  3. Activate the Plugin in WP-Admin
  4. Goto Settings > Related Posts to configure
  5. Optionally visit the Custom Styles tab to add any custom CSS styles. These are added to wp_head on the pages where the posts are displayed

Options:

Below are screenshots of the options available in the Settings screen

  1. contextual-related-posts screenshot 1

    CRP options in WP-Admin - General options

  2. contextual-related-posts screenshot 2

    CRP options in WP-Admin - Output options

  3. contextual-related-posts screenshot 3

    CRP options in WP-Admin - Feed options

  4. contextual-related-posts screenshot 4

    CRP options in WP-Admin - Custom styles

  5. contextual-related-posts screenshot 5

    CRP Widget

  6. contextual-related-posts screenshot 6

    Contextual Related Post metabox in the Edit Posts screen

If you disable automatic display of related posts please add <?php if(function_exists('echo_ald_crp')) echo_ald_crp(); ?> to your template file where you want the related posts to be displayed.

ChangeLog:

1.9.1

  • New: Meta box on the Edit Posts, Pages and custom post type pages to easily add the location of the URL of the thumbnail image
  • Modified: Refined match title algorithm. Previously this would match the post title with both the title and content
  • Modified: Widget initialisation
  • Modified: Massive code cleanup and more documentation in the WordPress settings page
  • New: Added w.org and github.com to list of allowed sites for timthumb

Read previous entries in the changelog.

Writing and testing plugins takes a good amount of time. If you like the plugin and find it useful and would like to donate something for my work please do click the Paypal Donate button below. The payment is secure. I haven’t filled in any amount. Feel free to donate what you please. Any amount is welcome. Thank you :)

License

All files and their contents are licensed under the GNU General Public License (GPL).

Questions or Bugs

Known Bugs

Please use the support forum if you have any questions or would like to report any bugs.

Languages

The following translations are available:

If you would like to make available a translation for the plugin, please do drop me an email.

Downloads

Download Contextual Related Posts
Number of downloads: 381,091
Last updated: May 10, 2014
Page on WP Extend

194 thoughts on “Contextual Related Posts plugin for WordPress

    • I thought about credit, wasn’t sure. I think I can do that as I did with my other plugin Add to Feed

      There is already a CSS style class for the related posts… it is called crp_related and is wrapped around the div.

      I’m working on the page results thingy :)

  1. Hi,

    Just upgraded to 1.1 and I’m receiving the following error when I try to reactivate:

    “Parse error: syntax error, unexpected T_STRING, expecting ‘)’ in /nfs/c04/h01/mnt/59463/domains/quovadis.soultopology.com/html/wp-content/plugins/contextual-related-posts/contextual-related-posts.php on line 103″

    any thoughts on how to resolve this?

  2. My wordpress said that an update was available for the contextual plugin. I clicked on the automatic upgrade and got the following error:

    Parse error: syntax error, unexpected T_STRING, expecting ‘)’ in /homepages/14/d253571688/htdocs/publicblog/wp-content/plugins/contextual-related-posts/contextual-related-posts.php on line 103

    Any ideas what I do now?

  3. This should be fixed now. I’ve released v1.1.1. You can download it from above.

    If you already have v1.1 or below installed, the update should show up in WP-Admin

  4. I would suggest deleting the two br tags after the div container. I noticed that this plug-in is what updated and borked my lay-out from the original plug-in Mark developed. There should be no reason br tags should be implemented in lay-out when it’s a simple matter of using margin or padding (padding if you’re concerned about IE6) in your template stylesheet. I’ve manually deleted the additional br tags for now, and am now updating my theme file to use the new function name.

  5. Also, I’m noticing that it’s picking up pages and listing them. Is there a quick way in your code to exclude pages? (I might suggest to include this as another option in settings in the future).

    I might also suggest changing the ‘pages’ reference in the settings to ‘posts’. There is a difference between pages and posts in most WordPress user’s minds, and it would probably eliminate any confusion as to what the function is for.

    Otherwise, very nice upgrade to Mark’s plug-in. I appreciate it.

  6. Sorry about the confusion. I must have missed the reference. I always ensure that it stays different.

    I think I can work on excluding the pages out. Will have to play around with a few options.

    Am updating the TODO list with these changes :)

  7. This is a very nice plugin, I just found it and am testing.

    Only question I have, is if there is a way to manually add related posts to a post, instead of letting them random.

    • Well, it isn’t really “random”. The related posts are based on the title and content of your posts.

      If you want to manually add related posts, you can just include it in the content of the post while compiling it.

  8. I upgraded to 1.2 just now but when I try to turn the plugin back on I get this:

    syntax error, unexpected T_OBJECT_OPERATOR in /public_html/wp-content/plugins/contextual-related-posts/admin.inc.php on line 38

    Can anyone help?

  9. [...] Contextual Related Posts – Display a list of contextually related posts for the current post. You can select the number of posts to display and if you want to automatically display the related posts in your content / feed. If you want to have similar posts due to similarity in titles or post content, you can select one of them. This can help in building internal links and so rankings are influenced due to this. [...]

  10. Hi, I found an errort to this plugin, before when I’m viewing a single post, it only has 30-60+ queries, but when starting to use the plugin it shows that a single post page has a 1900-2000+ queries. This is not n0rmal, it should I think only query the database less than 10 queries, kn0wing that it will only query 5 related post.

    Please fix this problem.
    This has an impact on my site.

    • I tried to unclick the option that it will base the related post on title and body, and now it is only basing on the title but still it has 700-1000+ queries.

      Please do an immediate action for this.
      Thank you!

        • I have a total of 1900 posts, and some of them has 200+ related posts.

          i already tried deactivating my plugins to see if there are any c0nflict but still it remains like that.

          What I noticed is that when you already have may post crp will surely query the database many times. Which is I think is not normal.

          Some of my post has only about 10 related post and crp has small db query. but when my post has many related post it queries many times.

  11. Hi, I know this probably isn’t the best place to ask, but the WordPress support forum is rarely helpful.

    The problem I am having does prevent me from using this plugin though, so I will ask here.

    I noticed that my feed is showing excerpts and summaries only, regardless of whether I have it set to use “Full Text” or “Summary”.

    This also is preventing certain plugins from showing up on the feed.

    This occurs with a fresh install of WordPress with zero plugins installed.

    Any ideas?

    • Honestly, I have no clue why you wouldn’t be able to serve full feeds. I haven’t seen this problem anywhere yet. Sadly, I guess the WordPress support forums are the best shot still…

  12. [...] Contextual Related Posts Contextual Related Posts WordPress plugin helps you display a list of contextually related posts for the current post. You can select the number of posts to display and if you want to automatically display the related posts in your content/feed. It doesn?t require the post to be tagged in order to display related posts and you can manually add related posts where you want them displayed [...]

  13. Hi,

    Really glad that I found this plugin as the Related Posts plugin that I was using is no longer supported by the author.

    If you are open to suggestions – I do have one point for improvement….

    The algorithm used to select related posts could do with some improvement and it would be really nice to see some additional options to influence the selection of related posts.

    R

      • Ajay,

        Thanks for responding…

        One of the reasons the “Related Posts” plugin from the other author was/is so popular is that he gave the plugin user several settings for fine-tuning the “related-ness” feature. Also, it seems to have a greater success at finding “very” related posts.

        Something else that would be nice would be to have an easy way of tailoring the display of the related post itself eg: date, author, excerpt etc…

        Are you planning on “evolving” this plugin?

        A tip… current users of the “other” plugin will slowly start to jump ship (so to speak) if the author remains AWOL for much longer. These folks will potentially be seeking a similar plugin and expect equal or better features.

        R

  14. Ajay,

    I like the idea of the plugin, and it seems to be working for a lot of people. Im probably missing something insanely easy. I installed it, activated it, checked the settings, but nothing appears to be different on my blog? Is there a specific way I need to insert it in each post? Thanks for your time!

    Joe

  15. [...] Contextual Related Posts Contextual Related Posts WordPress plugin helps you display a list of contextually related posts for the current post. You can select the number of posts to display and if you want to automatically display the related posts in your content/feed. It doesn?t require the post to be tagged in order to display related posts and you can manually add related posts where you want them displayed [...]

  16. Just a heads up. If you have a blog that has a lot of posts (more then a couple 1,000′s) this plugin breaks the front page. If you want to see an example, drop me an email and I’ll demonstrate.

    Thanks,

    Frank

    • Frank, care to elaborate. Both my blogs got a much more than a 1,000 posts. Same with several other blogs I am aware this plugin is on.

      • Great plugin, but I have a feature request.

        Can you make it so that when I’m editing a page or a post I can select whether I want that page in the index of related posts or not?

        Most of the content on my site is on pages and there are a few pages that I do not want showing up in my related content. But, I can’t find a way to only exclude a few pages.

        I’ve been looking at tons of plugins like yours, but none of them have this ability. I think it would really make yours stand out more than it already does.

        And, it’d be nice to not have to implement a work around :)

        Thanks!

          • Yeah, another thought is to make it so you can decide not to display the related posts on a particular post as well.

            Just having two checkboxes added to the sidebar when you’re editing a page or post would be simple but better than every other plugin :)

  17. Dear Ajay,

    I have a problem, Is it possible make Thumbnail to be equal proportion, Thumbnail all out of shape.
    (I ONLY WANT SET WIDTH OF Thumbnail)

    Thanks

    Sonic

    • I don’t have a perfect solution right now for the thumbnails. I am experimenting with using timthumb as a base for image resizing. However, this won’t be in the very near future.

  18. I have a bug in this plugin. It works very good in general, but for some reason it sometimes displays the very same article in its related pages/posts list. The link in this case doesn’t work, it directs to a non-existing page, resulting in the 404 page. Has this happened before? Any solutions?

  19. I tried the plug in and came up with an error. I could not see settings. When I tried to activated plug in. Nothing shows up at all. I will try and install manuel and see if that works.

  20. Hi,

    great work on this plugin.

    Only one thing I would really need more is the ability to add style to the image. Is that possible?
    something similar with “HTML to display before each list item” would be perfect, but maybe there is already a way to do it???

    another great addition would be the proportional image resizing, but that would be the sugar topping :)

    • Jean, you can use CSS to style the output created by the plugin. Instead of using a list, you can customise the output in the options to something else.

      • I’m trying to CSS the output into a horizontal list and having some trouble. Ideally I would like each item to have the thumbnail img on top with the post title text below and everything centered.

        As a starting point I added the following to my css file but it is not changing the output. What am I missing?

        /* Contextual Related Posts
        ———————————————————— */

        #crp_thumb .li {
        margin-left: 0;
        padding: 3px 15px;
        border-right: 1px solid #000;
        height: 180px;
        width: 150px;
        list-style: none;
        display: inline;
        }

        • Brad, I suggest changing the settings in the “Customise the output” section to change them to divs with class names and then style the divs. These are usually better to format than lists.

          • Thanks for the response. I got it to look mostly like I wanted except the thumbnail images were squashed and I could not figure it out. I had fun playing trying to make it work though.

  21. Hi, thank you for this great plugin. I am wondering that how do you decide which posts are related to given post? (I am not asking the full algorithm, i am just asking, for example, do you use tf/idf?)

    I was planning that store my post_post relations in a custom post_post table. But i think your approach is not this, right?

    • The plugin uses mysql’s inbuilt matching algorithm.
      I don’t save the related posts because the related list will never be static on a blog that keeps getting new posts. I still need to adapt the plugin for even better matches.

  22. I’d like to be able to exclude the related posts from appearing on certain categories or specific pages. I can prevent certain categories from appearing within the related posts list, but what I want is the other way round…! I want to include all categories/pages as being available for listing as related posts BUT I want to display the resulting lists on my entire website (except a few pages).

    It would be great to have on the Edit Post or Edit Page an option box allowing related posts to show or not show for the item being edited.

  23. Hi! How can I change the language on contextual related posts?

    I’ve finish to translate do Brazilian Portuguese and I’ve a crp-PO.po & crp-PO.mo files. Then… how can I use this files to translate your plugin?

    Thanks!

    Marinho
    WP-Brasil

  24. I want to change color of related post links because links have the same color with default link of theme. Can you help me to resolve this problem? Thank you very much!
    For example:
    color of normal related post link: red;
    color when mouse moves over: blue

  25. I’m using WordPress 3.1.4.

    Got this message when trying to activate the latest version plugin.

    Parse error: syntax error, unexpected T_OBJECT_OPERATOR in ******changguohua.com/wp-content/plugins/contextual-related-posts/contextual-related-posts.php on line 102

    please help…

  26. Awesome Plugin! Thanks!

    I will pick this over YARRP any day :-)

    Just a feature suggestion, it would be great to create a widget for this plugin. I have to display on sidebars using (PHP Code Widget) and it at times breaks stuff :-(

    Thanks Again

  27. Great Plugin.
    As I used a quite important custom taxomony in my posts i wanted the option to show the custom taxonomy.

    This is how I solved it.

    I added inside the “contextual-related-posts.php” after(after 119):

    if ($crp_settings['show_excerpt']) {
    $output .= ‘ ‘.crp_excerpt($search->ID,$crp_settings['excerpt_length']).”;
    }

    the following lines:

    /* Show Custom Taxonomy in related Posts – Christoph Daum – http://www.apermo.de */
    if ($crp_settings['show_custom_taxonomy']) {
    $custom = get_the_term_list( $search->ID, $crp_settings['show_custom_taxonomy'], ”, ‘, ‘, ” );
    if (!empty($custom))
    {
    $output .= ‘ – ‘.$custom.”;
    }
    }
    /* end Show Custom Taxonomy in related Posts*/

    And inside “the admin.inc.php”:
    After:
    $crp_settings[show_credit] = (($_POST['show_credit']) ? true : false);

    This:
    /* Show Custom Taxonomy in related Posts – Christoph Daum – http://www.apermo.de */
    $crp_settings[show_custom_taxonomy] = $_POST['show_custom_taxonomy'];
    /* end Show Custom Taxonomy in related Posts */

    —————

    After:

    <input type="textbox" name="excerpt_length" id="excerpt_length" value="”>

    This:

    Show a custom Taxonomy

    Name of a Custom Taxonomy
    <input type="textbox" name="show_custom_taxonomy" id="show_custom_taxonomy" value="”>

    Now you can show one custom taxonomy by giving its name after the excerpt. Feel free to add it to the following versions of this great plugin.

    Greets from Germany

  28. Hello,

    Thanks for the perfect plugin.

    Would you please show me how to display the date/month/year after the post title?

    * For example:

    Related Post:

    Export import post title (29.11.2011)
    Clinton trip tests the waters (28.11.2011)
    Mullet faces arraignment in beard case (28.11.2011)
    Solar plane promises new era of flight (26.11.2011)
    UK strikes biggest since ’89? (25.11.2011)

    Thanks and best regards,

  29. This is the best and only related posts plugin that works properly on my site with several thousand posts. The only think I’d like to suggest is that the thumbnail be physically resized because right now they are the same size at the original image. Any chance of that in a future version? Thanks!

    • Bryan, I’m working in the background to use timthumb for the thumbnails display. I plan on releasing a version when I am sure everything goes well (at least in my testing)

  30. Really happy to have found the only linking post widget that will work for my blog. Especially as a serious technophobe, the installation and editing is super easy. However i can’t figure out how to make the related posts appear in a horizontal list…?
    Thank you.

  31. Hi Ajay. I am trying to get the text to wrap around the featured images in the related posts output.

    I love the plug in. Please consider assisting me with this. Thank you!

    Also, I was wonder If I could text to wrap the images in the field named, “HTML to display before each list item:” ?

    or do I have to edit the plug in?

  32. Hello,

    I love how accurate this plugin is, but I’d really like to style the CSS for the results, for I don’t like the way the results look.

    First, they display in list style, but is it possible to display the results in one straight line (sort of like how LinkedWithin does)? If so, what would I need to add to my CSS style file?

    If that’s not possible, could you please tell me how to style the CSS so that the text is at least centered with the thumbnail? Right now, the thumbnail is displayed and the text shows up at the bottom of it, which leaves a great deal of empty space. Thanks so much for your help with this.

  33. Hello,

    One other possible change to the plugin I would suggest. Could you please provide an option to make the related links dofollow? This way, you could easily add some valid internal links which would help SEO, I believe. Thanks again for the great plugin.

      • Good question…I’m not sure. The only reason that I think the links are showing as nofollow is because I tested them with a Firefox plugin called SEO4Firefox. This plugin showed the links as nofollow. Thanks for checking on this though. I’ll go back and make sure that I haven’t accidentally made them nofollow with any of my blog’s settings.

  34. Hello,

    Just wanted to share what I did CSS-wise which formatted my posts kind of like LinkWithin plugin used to: Visit my site: http://www.mommylivingthelifeofriley.com to see what this style looks like.

    This is what I have in the Contextual plugin options page:

    Number of related posts to display: 3

    Title of related posts: Related Posts You Might Also Enjoy:

    HTML before posts:

    HTML before each item:

    HTML after each item:

    HTML after each post:

    Thumbnail dimensions: 120 x 120

    This is what I have in my CSS style file:

    /* contextual related plugin */

    #postcontent {width:550px;}
    #postcontent a {width:150px; margin:10px; text-decoration:none;}
    #postcontent img {display:block; border:3px solid #c5eeee; margin: 5px 0px 10px 0px;}
    #postcontent a:hover {color: #c5eeee;}
    #postcontent a:hover img {border:3px solid #CD1076;}
    #postcontent span {display:block; font-size:smaller;}

    Maybe this won’t work with particular themes, but I’m loving the way things look now! :) Hope it helps!

    • Melissa, thanks for the code. I like the way the related posts are being displayed on your site. I am currently working on a version that should include a few “themes”. Will release it if all goes as planned.

  35. Hello there, thank you for this plugin. I’ve styled it so that four square thumbnails display at the bottom of each post – I love the punch of color it displays: http://balancingeverything.com/2011/12/23/christmas-eve/

    I would like related posts to show in my feed as well, but since I’m using the thumbnails styled in a list, they display a bit odd – four large thumbnails stacked in a list.

    I’m currently using a different plugin to insert related links into the feed in a numbered text list, but I’d rather stick with yours. Is there a way I can have it keep the thumbnail display on posts but just do an ordered link list in the feed?

    Thank you very much!

    • Jessica, unfortunately, there is no way to do this directly right now without some code changes. But, I actually like this idea and I’ll put it in my to-do.

          • Sure, here’s my CSS:

            #crp_related ul{position:relative; top:0px; left:7px; padding:0px; margin:0px; display:inline}
            #crp_related ul li{display:inline}
            #crp_related ul li a{text-decoration:none; font-weight:bold; font-size:12px; padding:0px 2px 4px 2px}
            #crp_related img{padding:4px; background:#F9F9F9; border:1px solid #ccc}
            #crp_related img:hover{background:#ccc}

            :o)

          • Oh it’s just a little personal blog, I’m not worried about SEO at all – in fact I have search engines blocked from the site. But yes, if you were worried about search engine rankings, I’d keep the post titles in there under the thumbnails.

    • Note: I made it with php if(function_exists(‘echo_ald_crp’)) echo_ald_crp(); code but style corrupted. I tried with made code in single.php and comments.php but style not works like works on the top view.

    • HD, this feature hasn’t been built in. You’ll need to throw in some extra coding to truncate titles. I can put this on the todo list, but not sure if it will be out soon.

  36. Is there a way to see if CRP is driving clicks? Is there a way to look at analytics and see how people are using the plugin or would the only way be to track the % difference of page views once it is installed?

    • While you can’t drill down on percentages, a good proxy is to use my plugin Where did they go from here. This tracks which post your visitor clicks to from the current post.

  37. Hi Ajay – this might be a compatibility issue with my theme (photocrati) or some of my other settings/plugins but upon hitting activate, my entire site disappears (blank on firefox, internal server error on IE and chrome).

  38. For some unknown reason, it does not display any thumbnail, but only the default image. It sure does show the title and the excerpt (though I have already disabled it). Any suggestions?

  39. Hi I was using Contextual Related Posts, but Now i noticed that there is a problem in feed-burner email delivery to my subscribers because of this plugin. When i disabled Contextual Related Posts plugin feed-burner email delivery works. So please check this issue and let me the solution.

    Thanks
    Uday

  40. The plugin is really great, thank you.

    Found one problem: if I use category filter, plugin removes related posts from query result, so sometimes I get fewer related posts then expected (for example, if I set to show 5 related posts in options, after applying category filters I get only 3 posts on page) . Probably you should use category filter in the sql query.

    • In the mySQL filter I fetch 3 times than the limit, i.e. if you put 5, the query gets 15 related posts and then starts knocking off those that are to be filtered out.

      If you’re getting only 3 posts left, that means you’re category filter is too strong. I had thought about putting the category filter in the query, but am not sure about the additional overhead. Also it makes the query a lot more complicated than it already is.

  41. Well this plugin complete with several filter options to improve the results, I am also programming a plugin, I am researching the websites to get ideas and improve mine too, for now just did the base and is already great, will implement the function thumbnail that I have actually ready, and then it will create the content filter.

  42. This plugin in is amazing, thank you! It’s the best plugin for related posts I’ve used. I had a feature request:

    Would it be possible to limit the title/expert length on the widget separately from the output options? You already have separate options for the thumbnail size, so it would be an extension on that.

    Thanks again!

    • It’s a pity I have to delete your plugin. I just got this automated mail from my host, WP Engine:

      “Hi Sridhar Katakam,

      As part of the normal security and performance scans that WP Engine runs on our customer sites, we also scan for plugins that may be on our disallowed plugin list, and adversely affecting site performance and / or security.

      We just scanned your WordPress installation ‘sridhar’ and discovered [contextual-related-posts], which is/are on our disallowed list and will result in sub-optimal performance for your site.

      Our policy about plugins we don’t allow is here: http://support.wpengine.com/disallowed-plugins/.

      We’re sending you this email to request that you remove [contextual-related-posts] from your site within the next 7 days. In 7 days, we’ll automatically remove those plugins from your site, and we want to give you plenty of time to find and test suitable replacements. For many plugins, we have suggested replacements.”

  43. Hello!
    I found an error.
    If in the title used special character ‘ appears distorted link to image thumbnails

    sorry for my english

  44. Hi,

    I installed it on my established sites, but I’ve an issue with the plugin.

    It shows the related posts right below the post’s content, mean exactly where the post content ends. Is there a way to make the posts appear after the post content, after/below the share buttons?

    Please help, as the related posts do show within the html content of the post, making it look like the content of the post for the search engine robots. Hope you understand my problem.

    Looking forward towards your kind response soon.

    Thanks,
    Ali

    • You’ll need to edit your theme files and do the Manual Install. Please refer to the FAQ. If you have any further questions, please create a new topic in the support forum.

          • If you don’t have Use default style included in the plugin? selected, then you can set your own thumbnail sizes. If you want to set your own thumbnail size with this style, you can use the CSS code within css/default-styles.css and modify the height and width and other size settings there. You can then use this code within the custom CSS section

Leave a Reply