Custom Fields
Re-Envisioned
Support MB Relationships Color field in repeater.

  • Creator
    Topic
  • #31662
    Wojtek Piskorz
    Participant

    Hi.
    I'm using oxygen and metabox. I have 2 CPT. Product and Categories. Categories has some custom fields where one of it is "color picker".

    I need to create a repeater for this color picker. and codeblock with code:

    <?php
        $catColor = rwmb_meta('cat_color');
        echo $catColor; 
    ?>

    but I need to somehow dynamically adjust it for class because if I use:

    
    <?php
        $catColor = rwmb_meta('cat_color');
        echo $catColor; 
    ?>
    <style>
    
    .cat__bg-color {
    background-color: <?php echo $catColor ?>;
    }
    
    </style>

    its populates all with the first color it'll find on a page. Is there a workaround for that?

    (echo works - it is showing different #hex for each repeater element)

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #31670
    Long Nguyen
    Moderator

    Hi,

    You can pass the third parameter to the helper function rwmb_meta() to get the color of a specific post

    $catColor = rwmb_meta('cat_color', '', 12345);
    

    Refer to this documentation https://docs.metabox.io/rwmb-meta/

    If you want to get the post ID dynamically, please contact Oxygen support to ask for getting the post ID in the repeater module.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.