How to use a color picker field in Oxygen?

Support General How to use a color picker field in Oxygen?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #31472
    ameneses67@gmail.com[email protected]
    Participant

    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?

    https://www.screencast.com/t/P1lzEmEmy

    Thanks,

    #31476
    ameneses67@gmail.com[email protected]
    Participant

    How do I get the post ID dinamically?

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

    #31481
    Long NguyenLong Nguyen
    Moderator

    Hi,

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

    #31530
    ameneses67@gmail.com[email protected]
    Participant

    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 NguyenLong 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
    ameneses67@gmail.com[email protected]
    Participant

    It didn't work. Any other suggestions?

    Thanks,

    #31614
    Long NguyenLong Nguyen
    Moderator

    Hi,

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

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