3 Non-Obvious Applications of Post Relationships in WordPress
Toolset provides the most robust way of connecting post types using relationships in WordPress. Some obvious applications of post relationships are cross-connecting events and speakers or cars and manufacturers. We present 3 less obvious applications of cross-connecting posts to get you inspired with other practical usages.
If you’re new to Toolset post relationships, check out our introduction to what post relationships are and how they work or read through the whole section about using post relationships – videos included.
Let’s dive in and see how to use post relationships in diverse ways. And remember, these are only examples, you can use post relationships on any kind of content. You can also connect the same post type to multiple others or have multiple relationships between the same ones.
#1 Displaying Related Documentation Pages
You can use regular WordPress pages as documentation for your product and then connect these pages to a custom post type that tells more about the product.
This is what we did for our theme compatibility pages for WPML. The following image shows a page with compatibility information between WPML and Divi:
We use a custom post type for “Certified Themes” and regular Pages for documentation on how to use themes with WPML. In the example above, you can see the Divi theme and the highlighted link to the documentation page.
We have created a relationship between Pages and “Certified Themes”to cross-connect these two post types:
To display a list of related documentation pages we created a View and inserted it into the custom template for displaying single Certified Themes posts.
- Use regular WordPress Pages for your documentation.
- Create a custom post type for “Certified themes”.
- Go to Toolset → Relationships and create a many-to-many relationship between Pages and Certified themes.
- Edit the theme pages and connect them with corresponding documentation pages.
- Create a custom template for single-theme pages.
- In the template, display the content of your theme post and its custom fields.
- To display related documentation pages, you need to create a View. Because you are inserting the View inside a template for a specific post type, Toolset already has the information about related post types. It will allow you to easily display a list of connected pages.
Please note that you can create other post relationships for the same post type. Our example also displays a list of known issues for the current theme:
“Known issues” is another post type. We have created a relationship between Known issues and Certified themes post types.
Next, we edited our template for displaying single Certified theme posts and inserted another View into it. This View lists Known issues posts for a given theme.
#2 Displaying Outfits for WooCommerce Products
You can also connect custom post types with WooCommerce Products through relationships. For example, you could create the “Outfit” custom post type and connect specific outfits with relevant products to buy:
- Create the “Outfit” post type.
- Go to Toolset → Relationships and create a many-to-many relationship between Outfits and WooCommerce Products.
- Edit your Outfit posts and connect them with corresponding products.
- Create a custom template for displaying Outfit posts.
- To display a list of related products, insert the View block into your template for Outfits. When setting up the View, choose for it to display Products. Toolset will return all related outfits for a given product.
#3 Displaying 3rd-party Gallery Blocks Inside Single-post Templates
Nowadays, many block plugins offer beautiful blocks for displaying gallery images. The Advanced Gallery block from Kadence is a great example.
You might want to use these galleries inside your custom templates for single posts. In our example, we have a custom post type for “Tutors” and its content has a “Gallery” tab:
Here’s the same “Gallery” tab but this time, it uses a slider mode for the gallery images.
The challenge here is that there is no integration between Toolset custom fields and the 3rd-party gallery blocks. No worries – this is where using a one-to-one post relationship comes to the rescue.
- Create a post type for the content you need. In our case, it was Tutors.
- Create another post type, called Galleries. This extra post type will act as a container for your 3rd-party gallery block.
- Next, create a one-to-one relationship between these two post types.
- Now, when editing a Tutor post you can connect a Gallery post to it, like this:
- As the “Galleries” is a separate post type, you can click to create a new gallery post connected to the current Tutor. This will open an editor for creating a new gallery post. Then, insert the Kadence Advanced Gallery block into the editor:
We have also added a custom field to our Gallery post type that represents the gallery cover image. This is optional but can come in handy when displaying a list of all galleries.
To display the gallery inside your Content Template for tutors, you need to use the Toolset Single field block set to the Gallery post and the Post Content (body):
And that’s it! Now, our single Tutor posts display their image gallery using a fancy 3rd-party block, all thanks to a simple one-to-one post relationship.
This article is part of an ongoing series where we present interesting and powerful ideas of what you can build with Toolset. We’re publishing these every few weeks, so stay tuned!
Other articles in this series:
- 3 Tips For Creating Magazine-Like Layouts
- Design Beautiful Headers and Footers For Your Toolset Site
- How To Build A Custom Category Tree With Toolset
- How To Build A Truly Custom WooCommerce Store
- 3 Dynamic Designs Using Kadence Blocks To Inspire Your Website
- 5 Advanced Uses of Toolset’s Conditional Block in WordPress
Do you use post relationships on the websites you build? What’s your favorite usage of post relationships? Have any tips to share?
Share your thoughts with everyone in the comments!