2

我无法让 CSS 样式处理从 wordpress php 函数返回的内容:

<span id="featured-excerpt"><?php the_excerpt(); ?></span>

CSS 样式适用于摘录 php 之前或之后的任何内容,但摘录本身拒绝设置样式。我似乎取得任何成功的唯一方法是我尝试将 php 放在 span 标签内,这似乎不太正确,并在 php 输出之后创建一个新的单空格空白行......

<span id="featured-excerpt" <?php the_excerpt(); ?></span>

任何指针将不胜感激。

4

2 回答 2

1

在这种情况下......刚刚看了看:http ://codex.wordpress.org/Function_Reference/the_excerpt

完全有效:

<span id="featured-excerpt"><?php the_excerpt(); ?></span>

或者

<div id="featured-excerpt"><?php the_excerpt(); ?></div>

编辑(并给出评论):

尝试删除 php 函数并渲染文本,这样我们就会知道这是样式问题还是函数问题:

<span id="featured-excerpt">Lord help us!</span>

它是如何显示的?它是否显示在您的 HTML 输出中?

于 2012-10-13T00:34:53.280 回答
1

the_excerpt 函数与段落标签一起返回。最好的简单解决方案是调用 the_content 函数而不是 the_excerpt

the_content 提供您在内容框中添加的所有 CSS。

于 2015-02-10T19:15:00.447 回答