A lightweight solution for creating relationships between posts, terms and users in WordPress.
MB Relationships helps you create relationships between posts, pages, custom post type, terms and users. The plugin is lightweight and optimized for database and query performance.
The plugin allows you to create connections from posts to posts, posts to pages and so on. Then you can perform corresponding queries to retrieve posts that are connected to or from given posts.
It supports reciprocal and bi-directional relationships.
Post relationships is a missing part in WordPress. The only “built-in” way that mimic the post relationship in WordPress is the post_parent
for pages where you can create many child pages of a page (a one-to-many relationship). Unfortunately, that’s available for pages and hierarchical post types only. Besides, it’s not many-to-many relationship.
Below are some examples of posts to posts relationships that might help you see the benefit of this feature:
The simplest example is to manually create related posts in your WordPress website. When you edit a post, you can select posts that have similar or related content and display them in the frontend for further reading.
You can also query backward: displaying posts that link to the being read post as a reference to provide more information to your readers. With this, you don’t need a WordPress related posts plugin anymore.
Suppose you have two custom post types, event and band, where:
If people want to buy tickets, they could search for events in their location and see what bands are playing on a given date, or they could search for bands they like and see what date they are playing near their location.
In this example, we have created many-to-many relationships between events and bands.
MB Relationships allows you to create bi-directional connections. You will be able to query back and forth without any problem.
The data is stored in the database as a pair of (from_id, to_id), thus making it independent from either side.
Besides, for each side, there’s a meta box that shows what are connected from/to. So you don’t have to worry about the direction of the connection anymore.
MB Relationships is very much inspired by the popular plugin Posts 2 Posts which is not maintained anymore. We have taken the idea and made some improvements. The codebase and data structure is very similar.
WP_Query
,get_terms
and get_users
. See documentation for more information.This plugin is a free extension of Meta Box plugin, which is a powerful, professional solution to create custom fields and custom meta boxes for WordPress websites. Using MB Relationships in combination with other extensions will help you manage any content types in WordPress easily and make your website more professional.
If you like this plugin, you might also like our other WordPress products:
You need to install Meta Box plugin first
Install MB Relationships extension
'admin_filter' => true
to a side of the relationship settings. Works only for posts.API::each_connected()
not workingMB_RELATIONSHIPS_DELETE_DATA
to delete plugin data when uninstalling (#74)link="false"
link
parameter to admin_column
which accepts view
(default), edit
or false
(no link).mb_relationships_registered
hookfield
array for field settingsorder_from
and order_to
to API::add methodhidden
param work for to
sideorder_from
and order_to
columns to track order of items.$wpdb
and use the global variable directly. This prevents serialize objects in some unexpected situations.'post_type' => 'any'
as it relates to many queries.'post_type' => 'any'
in the query for relationship, which causes unexpected behaviour with post types that have 'exclude_from_search' => true
. Developers should always set post_type
in their queries. See https://bit.ly/2lPvnPk.