Support Forum
Support › MB Relationships › How to use CPT as alternative to Taxonomy in Beaver BuilderResolved
Hello,
I have an urgent project to finish, and I found that Taxonomies is problematic for what I need.
The goal is very simple. I have a CPT called "solutions" and Taxonomy for it called "solutions-category".
Every solution has it's own category... but it's not possible to create in Beaver Themer an archive that shows just the categories + name + featured image.
It always shows the posts related, but not just the category. WooCommerce does that, but they used a custom code for that.
A friend told me that since Taxonomy is not an element, this can't be done in a simple way.
So I try to understand how I can use a CPT for "solutions category" instead.
CPT: Solutions
CPT: Solutions Category
I know a relationship can solve this, but how do I do that in Meta Box is difficult to learn.
On one hand there are all the MB tools with GUI, and on the forum you always provide the code for functions.php.
Can you please direct me to a tutorial about that, or tell me the steps to do this.
Thanks
Dan
Hi Dan,
To connect Solutions to Solutions Category, you need to install MB Relationships extension. And then follow the extension docs. Basically, all you need is the following code in functions.php
:
add_action( 'mb_relationships_init', function() {
MB_Relationships_API::register( array(
'id' => 'solutions_to_solution_categories',
'from' => 'solution',
'to' => 'solution_category',
) );
} );
Then you can select connected solution categories when you edit a solution.
To get the connected solution categories to show on the frontend, I think it's hard to do in BB, since it doesn't support to make custom query with custom arguments yet :(. The way you query related posts is described here.
Thanks Anh,
I got all the extensions installed... but I was hoping to be able to use the graphic interface and not code right now, just don't have time to learn this...
I guess most of the work with MB is done with code, and not with the plugin interface like Pods Types or ACF.
Thanks
Dan
Hi Dan,
For this purpose, yes, coding is required. We're updating the Builder to make it supports more features in the Meta Box and extensions. But for now, it's not there yet.