Creating Many to Many Relationships Between Posts in WordPress

Written By Barry Kooij ON September 29, 2016

Ever worked on a WordPress website and wondered how to link posts to each other? Or how to link one of your custom post types to another? After some searching you’ll find that this isn’t possible with WordPress out of the box.

This isn’t something new. Not being able to create these many-to-many relationships has been a shortcoming of WordPress since day 1. There are some ways to solve this. Misusing Taxonomies is one (not recommend) way. Another way is using one of the few plugins out there that solve this problem. Post Connector and Posts 2 Posts are both examples of plugins solving this issue in their own way. With Post 2 Posts now officially being deprecated, many users are looking for an alternative.

A Great Posts 2 Posts Alternative

With Scribu announcing Posts 2 Posts will no longer receive any updates in any form, users of the plugin are actively searching for an alternative. Instead of waiting for one of the promised forks, why not check out a product that’s been used in production for over 3 years? Although Post Connector is setup in a different way than Posts 2 Posts under the hood, most solutions you can build with Posts 2 Posts can also be created with Post Connector. With Posts Connector Premium’s API you can also custom code your own solutions with ease.

Some Post Connector Implementations

It’s hard to explain what Post Connector does. Honestly, I find myself almost instantly using examples on how to use it instead of explaining what it does. And that’s what I’ll be doing here as well. Here are some examples of Post Connector in the wild.

Episode Sponsors on OfficeHours.fm

On the OfficeHours.fm podcast, Carrie interviews a variety of people within the WordPress ecosystem. From plugin developers to marketers to business owners. Businesses have the option to sponsor an episode. Among other things, sponsors are shown as the episode sponsor on the episode’s archive page. Instead of adding the sponsors manually to each episode, OfficeHours.fm uses Post Connector to link episodes to sponsors. This way sponsors only have to be added to the website once and can be linked to an episode easily.

OfficeHours.fm links Sponsors to Episodes making them the Episode Sponsors

OfficeHours.fm links Sponsors to Episodes making them the Episode Sponsors

Plugins Used on the Never5 Blog

We use Post Connector our own blog, the one you’re reading right now. We’ve setup a connection between a custom post type Products and our blog posts. This way we can link one or multiple products we used in a post, to the post. At the bottom of the post we display these linked products in a block Products Used in This Post. The screenshot below is taken from our Increase the Size of Your Mailing List by Offering Free Downloads post. You can also see it live in action at the bottom of this post!

We're using Post Connector to link our products manually to our posts

We’re using Post Connector to link our products manually to our posts

Recipes on Love & Olive Oil

Love & Olive Oil posts about recipes for your sweet tooth, with a whole lot of cute treats mixed in! All these delicious recipes require products to create them. Products like ingredients but also products like an ice cream spoon. Instead of having to re-type these products on every recipe, they decided to create a custom post type Products. With Post Connector they connected their recipes to products. This way they have one central place to manage their products, saving them a lot of time creating and maintaining them.

Love & Olive Oil connects the products used in their recipes with Post Connector

Love & Olive Oil connects the products used in their recipes with Post Connector

Products Used in This Post

  • Post Connector

    In WordPress, post types are often related, for instance, you might want to relate recipes to ingredients. But to do so, you’d normally have to use a custom taxonomy. With Post Connector you can directly relate post types to post types, foregoing all the hassle of having to create loads of custom taxonomies and just allowing you to do what you really want to do.

Leave a Reply

Your email address will not be published. Required fields are marked *