Add number to my relationships

Support MB Relationships Add number to my relationshipsResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #27521
    quentinolivier.swisscreaweb@gmail.com[email protected]
    Participant

    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 :

    • Elementor
    • Elementor Pro
    • MB Blocks
    • MB Custom Post Types & Custom Taxonomies
    • MB Frontend Submission
    • MB Relationships
    • Meta Box
    • Meta Box - Elementor Integrator
    • MB Builder
    • MB Conditional Logic

    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!

    #27553
    Long NguyenLong Nguyen
    Moderator

    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:

    • Create a cloneable group
    • Create subfields: post, image, text, number

    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/

    #27566
    quentinolivier.swisscreaweb@gmail.com[email protected]
    Participant

    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! 🙂

    #42165
    dan@iam39.com[email protected]
    Participant

    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

    #42170
    dan@iam39.com[email protected]
    Participant

    Don't worry I sorted it, my group had the same id as my post. Thanks anyway 🙂

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.