Color field in repeater.

Support MB Relationships Color field in repeater.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #31662
    Wojtek PiskorzWojtek 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)

    #31670
    Long NguyenLong 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 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.