Skip to content

matthiassiegel/Related

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Please note

This plugin has a new owner, the version hosted here is outdated. For the latest version please visit https://wordpress.org/extend/plugins/related/

Related

A simple 'related posts' plugin that lets you select related posts manually instead of automatically generating the list.

Tested on WordPress 2.9 - 3.3

Websites:

Description

A simple 'related posts' plugin that lets you select related posts manually instead of automatically generating the list. Supports any post types in WordPress, including custom ones.

Features:

  • Add related posts to your blog posts, pages etc.
  • Choose from posts, pages or any other post type
  • Support for custom post types
  • Re-order related posts via drag and drop
  • Custom markup possible, or simply use the default output

I wrote the plugin because I wanted to have the option to add related posts to each blog post using a simple but functional plugin without a lot of junk. Unlike other 'related posts' plugins that use algorithms to automatically generate a list of posts, I wanted to be able to select the related posts myself.

The plugin targets small and medium sized blogs. On blogs with lots of posts (500+) it might not be very comfortable to choose the posts via select box.

You can contribute improvements to this plugin by forking it and submit a pull request.

To display the related posts, simply add the following line in your template, inside the WordPress loop.

<?php echo $related->show(get_the_ID()); ?>

to your template, inside the Wordpress loop. For advanced options, see the installation docs.

Installation

Option 1 - Automatic install

Use the plugin installer built into Wordpress to search for the plugin. Wordpress will then download and install it for you.

Option 2 - Manual install

  1. Make sure the files are within a folder.

  2. Copy the whole folder inside the wp-content/plugins/ folder.

  3. In the backend, activate the plugin. You can now select related posts when you create or edit blog posts, pages etc.

How to display the related posts on your website

The related posts are displayed by adding

<?php echo $related->show($post_id); ?>

to your template. Replace $post_id with a post ID. If you call it within the Wordpress loop, you can use

<?php echo $related->show(get_the_ID()); ?>

You have the option of either outputting a pre-formatted list or returning a PHP array of related posts to customise the markup yourself.

Examples

Example 1: Using the default output

<?php echo $related->show(get_the_ID()); ?>

This can be called within the Wordpress loop. It will output a <ul> list with links.

Example 2: Returning an array

<?php $rel = $related->show(get_the_ID(), true); ?>

With the second argument set to true, it will return an array of post objects. Use it to generate your own custom markup. Here is an example:

<?php
    $rel = $related->show(get_the_ID(), true);

    // Display the title of each related post
    foreach ($rel as $r) :
        echo $r->post_title . '<br />';
    endforeach;
?>

Frequently Asked Questions

1. Who should use this plugin?

People who want to list 'related posts' in their blog posts or pages, and want to choose the related posts themselves, instead of having a list generated automatically like other plugins do, using weird algorithms that often create comical results.

2. Where does the plugin store its data?

Data is stored in the existing postmeta table in the WordPress database. No additional tables are created.

3. How many related posts can I add?

As many as you like, there's no limit.

4. Wordpress version 2.9 is listed as minimum required version. Any chance it will work with earlier versions?

There's a chance it will work with earlier versions, but I haven't tested it.

5. I have 500+ posts on my blog and selecting the posts with the one select box isn't very comfortable, lots of scrolling.

That's true, it isn't ideal for large blogs. This might get improved in future releases, feel free to submit ideas.

6. In WordPress 2.9, a strange error appears when I try to delete the plugin.

Yes, I don't know what the problem is. It's only in WordPress 2.9. Just delete the plugin directory manually from wp-content/plugins.

7. When I delete the plugin, will it delete the related posts data?

With version 1.1, all data remains in the database when the plugin files are deleted through the plugins page in WordPress. So if you accidentally delete the plugin, or if you decide to install it again later, your data should still be there.

8. Is this plugin actively maintained?

Unfortunately not anymore, because my focus is on Ruby and JS development these days.

Changelog

1.1.1

  • Minor rewrites that may prevent interference with other plugins

1.1

  • Bugfix: related posts are now correctly saved (deleted) when all related posts are removed from the current post
  • Feature: all post types in WordPress are now supported (including custom ones)
  • Improvement: select box now sorts posts by title and displays post type
  • Improvement: current post is now excluded from the list of posts
  • Improvement: data now remains stored in database when plugin is deleted, to avoid accidental loss of data
  • Improvement: general code quality improvements

1.0

  • Initial release. No known issues.

Upgrade Notice

Either let WordPress do the upgrade or just overwrite the files.

About

A simple related posts plugin for WordPress

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published