Custom Fields
Re-Envisioned
Support General How to use a color picker field in Oxygen?

  • Creator
    Topic
  • #31472

    Hi;

    I created a custom color picker field for posts. How can I use this color in an Oxygen color field when creating the single post template?

    10.23.2021-15.34.05

    Thanks,

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #31476

    How do I get the post ID dinamically?

    rwmb_meta( 'text_fieldID', '', 12345 );

    #31481
    Long Nguyen
    Moderator

    Hi,

    Please refer to this topic to get the color picker value in the Oxygen builder https://metabox.io/support/topic/metabox-settings-page-color-picker-css-variables-oxygen/

    #31530

    Hello,

    I'm trying to get the MB color picker value from the current post, not from a settings page.

    This is what I have and works well, but it has a specific post ID (281). How can I pull the current post ID instead of having a fix value?

    add_action( 'wp_head', function () { ?>
    <style>
    :root {
    /*Begin First Varible Code*/
    --primary-1: <?php 
            $primary_color_1 = rwmb_meta( 'primary_hero_bg_color_1', '', 281 );
            echo $primary_color_1;
            ?>;
    ;
    /*End First Varible Code*/
    
    /*Begin Second Varible Code*/
    --secondary-1: <?php 
            $secondary_color_1 = rwmb_meta( 'secondary_hero_bg_color_1', '', 281 );
            echo $secondary_color_1;
            ?>;
    ;
    /*End Second Varible Code*/
    }
    </style>
    <?php } );

    I tried rwmb_meta( 'primary_hero_bg_color_1 ); expecting to get the value from the current post but it didn't work.

    Thanks in advance for your help.

    #31537
    Long Nguyen
    Moderator

    Hi,

    You can try to use the WordPress function get_queried_object_id() to get the current post ID.

    $primary_color_1 = rwmb_meta( 'primary_hero_bg_color_1', '', get_queried_object_id() );
    
    #31606

    It didn't work. Any other suggestions?

    Thanks,

    #31614
    Long Nguyen
    Moderator

    Hi,

    Please try to contact Oxygen support to ask how to get the current post ID on their builder.

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