高级自定义字段CSS

时间:2017-07-13 15:07:27

标签: css wordpress advanced-custom-fields

我有一个通过ACF构建的团队页面。我有5个成员,每个成员都包含一个"查看个人资料"按钮。

如何使用ACF为每个按钮指定不同的颜色代码?

 <button style="width:25%; float:right;"><a href="#">View Profile</a>.</button>

1 个答案:

答案 0 :(得分:0)

ACF插件有一个颜色选择器字段选项,您可以将其包含在团队成员字段组中:https://www.advancedcustomfields.com/resources/color-picker/

所以你可以在模板中做这样的事情:

<a href="#" style="width:25%; float:right; background-color:<?php the_field('button_color'); ?>">View Profile</a>

请注意,为了清楚起见,我删除了您的按钮包装器。你可能真的不想在<a>中包含<button>,但我猜你是因为某些造型而这样做了。有一个按钮类可以应用于<a>,以便为它提供更好的样式,具体取决于您正在使用的主题。

相关问题