html - 如何根据 acf 设置简码样式
问题描述
我想将我页面中的 acf 字段的输出与我的简码结合起来。文本应使用通过 acf 字段设置的颜色加下划线。
我尝试调用字段颜色并通过内联样式设置文本装饰。但这不起作用。任何想法我做错了什么?
function quote_func($atts, $content = null){
$color = get_field('color');
$output = '<div>';
$output .= '<span style="text-decoration-color:' . echo the_field('color'); . '">' . $content . '</span>';
$output .= '</div>';
return $output;
}
add_shortcode( 'quote', 'quote_func' );
解决方案
您应该回显您在函数开头设置的变量。
function quote_func($atts, $content = null){
$color = get_field('color');
$output = '<div>';
$output .= '<span style="text-decoration-color:' . $color . '">' . $content . '</span>';
$output .= '</div>';
return $output;
}
add_shortcode( 'quote', 'quote_func' );
推荐阅读
- python - SciPy Delaunay三角剖分改变了单纯形的多个点,以实现参数的微小变化
- javascript - 动态生成json文件
- ios - 带有 MVVM 的 RxSwift,RadioButton 不起作用
- javascript - TypeError:url.parse 不是函数(从 sanity.io 获取数据)
- simics - 是否可以在 simics 中看到 smbase?
- java - OData 是否支持 http/2.0?
- typescript - 无法在 typescript 中导入 Node js 集群
- azure - Azure Blob 存储 - 尝试使用 C# 使用 API REST 删除 Blob 时出错
- r - dplyr 没有正确过滤日期
- pyinstaller - Pyinstaller 没有这样的文件或目录: