Support Forum
Support › MB Relationships › Add number to my relationshipsResolved
Hello,
I took the extension a little while ago, knowing ACF well, I would like to create a site (test) to store recipes.
I have created my two CPTs:
- Ingredients
- Recipes
I created a relationship between these two CPT and I would like, when I choose my different ingredients, to add a quantity to them (and then display everything directly)
I use as extension :
So I haven't coded anything if I have to, no worries I'll go through it!
Also while I'm at it for each ingredient I put an image in front of them, how can I get this information in my page template elementor ?
Visually I would like to put : image ingredient - name ingredient - quantity
Thank you very much!
Hi,
It's not possible to add a field value to a connection post by using MB Relationships. But there is a field type post
which works similar to Relationships. Here are some guides for you:
Assign the meta box to the CPT Recipes so each cloneable group you can select a post Ingredient, add images, text (name), number (quantity).
Get more details on the documentation
https://docs.metabox.io/extensions/meta-box-group/
https://docs.metabox.io/fields/post/
Thank you for your reply!
I have a problem with this because if I want to make something clean, it means that the person has to manually retrieve the image of the ingredients each time...
I'm looking at both your documentations thanks to you! 🙂
Hi Long Nguyen,
Apologies to resurrect this post, but this was exactly the information I needed. If I wanted to display this on the single post template, how would I do this? It gives me the following PHP, but it doesn't seem to do anything.
<?php
$groups = rwmb_meta( 'plots' );
foreach ( $groups as $group ) {
// Field plots:
$post_id = $group[ 'plots' ] ?? '';
?>
<p>Selected post ID: <?= $post_id ?></p>
<?php
// Field quantity:
echo $group[ 'quantity' ] ?? '';
}
?>
Thanks again
Dan
Don't worry I sorted it, my group had the same id as my post. Thanks anyway 🙂