Support Forum
Hello,
I want to display the colors choosen by the color picker I added to all my post.
I watched this video: https://www.youtube.com/watch?v=mjLsbRgQ2k4
I followed the steps the guy did, but it doesn't work for the post section.
I added this code in wp_header:
<div>
<style>
:root {
/<em>Begin First Varible Code</em>/
--background-color: <?php
$background_color = rwmb_meta( //Change the variable to your desired varible name
'background_color_picker', //Color Picker ID
['object_type' => 'Post'],
'post' ); //Option Name from Settings Page
echo $background_color;
?>;
;
/<em>End First Varible Code</em>/
}
</style>
</div>
This are my fields I added to my posts:
<div>
$meta_boxes[] = [
'title' => __( 'Extra Post Fields', 'your-text-domain' ),
'id' => 'extra-post-fields',
'storage_type' => 'custom_table',
'table' => 'wp_mb_extra_post_fields',
'tabs' => [
'tab_21kcpojc8ia' => [
'label' => 'Color Tab ',
'icon' => 'dashicons-admin-appearance',
],
'tab_kbam38nta9i' => [
'label' => 'Video and featured image',
'icon' => 'dashicons-format-video',
],
'tab_xlkmse8nuu' => [
'label' => 'Download Button 1',
'icon' => 'dashicons-upload',
],
'tab_kv6sob7ra9q' => [
'label' => 'Download Button 2',
'icon' => 'dashicons-upload',
],
],
'fields' => [
[
'name' => __( 'Background color', 'your-text-domain' ),
'id' => $prefix . 'background_color_picker',
'type' => 'color',
'alpha_channel' => true,
'tab' => 'tab_21kcpojc8ia',
],
[
'name' => __( 'Hide Featured image ', 'your-text-domain' ),
'id' => $prefix . 'text_a1fp2hdgzzt',
'type' => 'text',
'desc' => __( 'Type "yes" to hide | Leave empty to show', 'your-text-domain' ),
'tab' => 'tab_kbam38nta9i',
],
[
'name' => __( 'YouTube URL', 'your-text-domain' ),
'id' => $prefix . 'url_vdnpr9wzws',
'type' => 'url',
'tab' => 'tab_kbam38nta9i',
],
[
'name' => __( 'Video Embed', 'your-text-domain' ),
'id' => $prefix . 'wysiwyg_9s5x8ccyr3',
'type' => 'wysiwyg',
'sanitize_callback' => 'none',
'tab' => 'tab_kbam38nta9i',
],
[
'name' => __( 'Affiliate discosure', 'your-text-domain' ),
'id' => $prefix . 'select_rjsjhddfon',
'type' => 'select',
'options' => [
'Commissions may be earned from the links above. If you purchase plugins with these links, I will receive a small commission at no additional cost to you. Thank you!' => __( 'Commissions may be earned from the links above. If you purchase plugins with these links, I will receive a small commission at no additional cost to you. Thank you!', 'your-text-domain' ),
'Not sponsored or affiliated, just sharing to help out the music production community.' => __( 'Not sponsored or affiliated, just sharing to help out the music production community.', 'your-text-domain' ),
],
'tab' => 'tab_xlkmse8nuu',
],
[
'name' => __( 'Download title', 'your-text-domain' ),
'id' => $prefix . 'text_fop15u4ojpf',
'type' => 'text',
'tab' => 'tab_xlkmse8nuu',
],
[
'name' => __( 'Button text 1', 'your-text-domain' ),
'id' => $prefix . 'text_40hi0nvtvmw',
'type' => 'text',
'tab' => 'tab_xlkmse8nuu',
],
[
'name' => __( 'Download Link 1', 'your-text-domain' ),
'id' => $prefix . 'url_f0t8ukl11vj',
'type' => 'url',
'tab' => 'tab_xlkmse8nuu',
],
[
'name' => __( 'Button text 2', 'your-text-domain' ),
'id' => $prefix . 'text_ui1dobxqbif',
'type' => 'text',
'tab' => 'tab_kv6sob7ra9q',
],
[
'name' => __( 'Download Link 2', 'your-text-domain' ),
'id' => $prefix . 'url_n93zhbdfdj',
'type' => 'url',
'tab' => 'tab_kv6sob7ra9q',
],
],
];
</div>
<style>
Here is how if shows up in my website:
<div>
:root {
/<em>Begin First Varible Code</em>/
--background-color: ;
;
/<em>End First Varible Code</em>/
}
</style>
</div>
Can you please help me?
Thanks