我需要在Wordpress中为这个php代码添加样式。我怎么做到这一点,我迄今为止所尝试的一切都没有用。
<?php echo the_field('section_text'); ?>
这是我目前的代码。
<div id="inner-content" class="wrap cf">
<p class="quote-text" style="font-family: 'Josefin Slab', serif; font-size: 1.5em; line-height: 30px; text-align:justify; color:#664422; font-weight:bold; "><?php echo the_field('section_text'); ?></p>
</div>
答案 0 :(得分:0)
我假设你正在使用ACF插件。使用echo
时不应使用the_field()
。
试试这段代码。
<div id="inner-content" class="wrap cf">
<p class="quote-text"><?php echo get_the_field('section_text'); ?></p>
</div>
答案 1 :(得分:0)
首先,您不需要回复the_field
。所以正确的代码可以是
<?php the_field('section_text'); ?>
或
<?php echo get_field('section_text'); ?>
现在,我猜测名为'section_text'的字段是一个文本编辑器字段,其输出包含像段落一样的html代码。然后将您的代码更改为此。
<div id="inner-content" class="wrap cf">
<div class="quote-text"><?php echo get_field('section_text'); ?></div>
</div>
现在将以下css添加到主题styles.css
.quote-text p , .quote-text * {
font-family: 'Josefin Slab', serif;
font-size: 1.5em;
line-height: 30px;
text-align:justify;
color:#664422;
font-weight:bold;
}
如果有效,请告诉我。