css - 操纵 wordpress "the_content"

标签 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)

最佳答案

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

关于css - 操纵 wordpress "the_content",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31884485/

相关文章:

wordpress - 我在 Wordpress 中的菜单无缘无故换行。

html - 为什么我的 <UL> 不会扩展以包装它包含的 <LI> 元素?

html - 带边框的 HTML 元素的偏移 anchor 以针对固定标题进行调整

html - 为什么允许将 bgColor 添加到 <head> 和 <table> 标签作为属性

jquery - 如何通过更改 css 实现这样的滚动 div?

php - 显示 WooCommerce 迷你购物车中的商品数量

html - 如何从 HTML 页面中删除长水平滚动条

css - 使用 div 行 80% 和 20% Bootstrap 整页

css - 如何使用 Google 检查和编辑页面和样式?

wordpress - 本地WordPress安装仅显示主页,所有其他页面均未找到