douying8666 2018-01-06 15:43
浏览 56
已采纳

内联CSS的get_post_meta [关闭]

I have a custom field with name and value (case sensitive) as follows: style; rgb(240,180,41)

The code to retrieve this is included within the loop on my single.php file:

    <h2 style="
text-shadow: 2px 2px <?php get_post_meta(get_the_ID(), 'style', true); ?>; 
-webkit-text-stroke: 1px <?php get_post_meta(get_the_ID(), 'style', true); ?>;">

The h2 on the page has a 2px 2px shadow and a 1px outline, but it is not pulling through the custom color as specificied in the 'value' field of the custom field.

Any help much appreciated!

  • 写回答

1条回答 默认 最新

  • duanhuokuang5280 2018-01-06 16:01
    关注

    get_post_meta will only return the value, you should put echo in it when displaying the value;

    something like;

    <?php $color =  get_post_meta(get_the_ID(), 'style', true); ?>
    <h2 style="
        text-shadow: 2px 2px <?php echo $color; ?>; 
        -webkit-text-stroke: 1px <?php echo $color; ?>;
    ">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 CSS实现渐隐虚线框
  • ¥15 有没有帮写代码做实验仿真的
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题