操纵wordpress" the_content"

时间:2015-08-07 18:33:17

标签: css wordpress

我正在WP网站上工作。对于文章页面,我使用<?php the_content(); ?>来提取我所在的帖子页面的内容。我需要操纵第一段的第一个字母。幸运的是,第一段似乎有一个独特的excerpt类。我能够做大,改变字体等,但在颜色方面会出现问题。

网站上有六个单独的部分。每个人都有自己的颜色。我需要那封信是合适的颜色。但是,当它声明第一段属于excerpt类时,它已经不在我的手中了,所以我无法动态添加颜色或添加一个唯一的类名,等

思想?

根据要求编辑一些代码:

<div class="postExcerpt">
<span class="author">Bob Smith</span>
    <br/><br/>
(this is where I call the_content() and it generates the following <p> tags. Oddly enough, when I Inspect Element, I see that the first one has a class of `excerpt`, but when I view source, it doesn't)
<p>Blah Blah BlahBlah Blah BlahBlah Blah BlahBlah Blah BlahBlah Blah Blah</p>
<p>Blah Blah BlahBlah Blah BlahBlah Blah BlahBlah Blah BlahBlah Blah Blah</p>
<p>Blah Blah BlahBlah Blah BlahBlah Blah BlahBlah Blah BlahBlah Blah Blah</p>
<p>Blah Blah BlahBlah Blah BlahBlah Blah BlahBlah Blah BlahBlah Blah Blah</p>
(out of the_content() call)

1 个答案:

答案 0 :(得分:0)

最后,我所做的是意识到我控制了父元素。所以我在php文件中动态重命名它以反映我所在的部分然后我为每个新部分创建了CSS并对p执行了操作:first-of-type:first-letter并且它有效。