Dukeo » WordPress » Custom Post Relationships: Built Your Own with WordPress

Custom Post Relationships: Built Your Own with WordPress

Steven 31 responses WordPress

In your effort to build cross-links between your various post pages, you might be using some “related posts” WordPress Plugins. But from time to time, the way it decides the related posts might seem a little obscure and you might prefer some other posts to show in your “related posts” list.

Why using Custom WordPress Post Relationships?

Most of the “related posts” plugins out there rely on an algorithm and the results are automatic. With Custom Post Relationships (CPR), you get total control as you can manually select the posts that you want to relate. It can definitely be worth the extra 5 minutes of work if you have a linking strategy in place.

wordpress plugin custom post relationships

When you create or edit a new post you will see a screen similar to the screenshot. In this option panel, you can choose how many posts you want to see, in what order, from what category to pull posts from and of course you can filter the results by typing a few letters from any part of the post title. Then all you have to do is add the posts to the Related Posted pane by clicking “Add”. In the related posts pane you have the ability to reorder the posts just by dragging and dropping.

And that’s it actually. Your post is now in a relationship with a series of posts that YOU chose. Can you imagine the possibilities?

How To Display Custom WordPress Post Relationships

Open your single.php file (in your theme folder) and locate the place that your want to display your related posts. Copy this snippet of code:

<div id="related">
<h2>Related Entries</h2>
$relations = cpr_populate(get_the_ID());
if (!empty($relations)) {
echo "<ul>";
foreach ($relations as $related) {
echo "<li><a href='".get_permalink($related->ID)."'>".$related->post_title."</a></li>";
echo "</ul>";
else {
echo "<p>No related entries</p>";

This small piece of code will create a new section (div id=”related”) with a section title (Related entries) and will display an unordered list with the related posts.

Aditionally, you can pull more information from posts to display in the “Related Posts” list. For example, you can display the post thumbnail by posting the following code:

get_the_post_thumbnail($related->ID, 'thumbnail')

Download Custom Post Relationships Here.

If you enjoyed this article,
Get email updates

Join for Free »


  1. Web Design Studio

    logical and simple…I like it!

  2. Sad Music

    Will try this on my website soon!

    1. Don’t forget to report your experience here.

    2. Sad Music

      I want to know what other areas I can cover

  3. Flash Games

    Can you point me to a web link where this is already implemented?

  4. Dana

    Interesting post….great WordPress help for those of us getting started on it!

  5. Gorman

    Very informative.

  6. Michelle

    Excellent suggestions on enhancing your WP experience.

  7. Shad

    When was this launched?

    1. I have no idea. You can always check the ‘About’ page of the plugin.

    2. Shad

      Thanks…appreciate it.

  8. Affmaster

    Good example of engagement models on blogs.

    1. Liz

      I like helpful blogs with DOABLE stuff rather than the preachy ones!

    2. Webdesign Studio

      DOABLE blogs are more popular as well! Guess why? It’s more interactive, that’s why!

  9. Mitch

    Hey…Sharing IS caring!

    1. Thank you Mitch ;)

    2. Mitch

      The pleasure is mine Steven!

  10. Liz

    I enjoyed reading this post. Hope to implement it soon.

  11. Chris

    Is WordPress the ideal blogging platform?

    1. Of course it is. There is not secret why it’s used by almost everybody.

    2. Liz

      I too agree with you. WP is convenient and user-friendly. That’s why it’s so popular!

    3. Sad Music

      …and you have got amazing WP plugins as well!

  12. Web Design Studio

    Do all websites need to have a blog?

    1. Affmaster

      Not really…only if you have something worth talking on a regular basis.

    2. Dana

      And to add to this..I would say Interact as much as possible with your blog followers.

    3. Affmaster

      But, your interaction should be contextual.

    4. Dana

      Yup! Mostly subjective but a casual approach isn’t all that offending I believe, as long as you’re within limit.

  13. Anon

    A good blog can be an asset for SEO

    1. Sad Music

      But, I believe to be SEO friendly you need to have the right mix of keywords and key phrases at the right places.

    2. First Website

      But first you need to have a good strategy in place. Isn’t it Steven?

  14. Nice and informative post!