[英]How to get post meta meta key and meta value of wp color picker field
我在自定义metabox中创建了一个输入字段,并将其链接到jquery中的wpColorPicker对象,使其成为颜色选择器字段。但是我不知道要获取meta键来显示该值,我的代码是:
<label for="title-background-color">Choose background color: </label>
<input type="text" name="title-background-color" id="title-background-color"
class="title-background-color" value="#dddddd" data-default-color="#dddddd">
我想在这里展示
<div class="post-title-under-header" style="background: `i want that value here` ;">
<div class="post-title-under-header">
<?php the_title('<h1>', '</h1>');?>
</div>
</div>
要使用class post-title-under-header
设置元素的背景色,您可以使用jQuery做类似的事情。 在此示例中,背景颜色将在change
事件中change
。
$(document).ready(function(){
$('#title-background-color').on('change',function(){
$('.post-title-under-header').css('background-color',$('#title-background-color').val());
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.