CSS无法操作文本,它只是一种用于样式化内容的语言。
但是您正在使用PHP - 只需让PHP输出您最初想要的任何内容即可。
<?php echo str_replace('p>', 'whatever>', get_the_excerpt()); ?>
preg_replace("/<\\/?p(\\s+.*?>|>)/", "", $string);
参考:https://dev59.com/FEnSa4cB1Zd3GeqPLiov - node_modulesstr_replace()
不关心你要替换什么 - 如果你替换了在内容中找到的字符串,它就会起作用。 - VoteyDisciple<p>
标签在页面上是可见的。但在标记语言中,它不应该是 <p>
,而应该是 <p>
。 - VoteyDisciple这里是需要翻译的内容:
函数the_excerpt()
会在返回中输出,所以不要使用echo(推荐在wp循环中使用)。如果需要使用echo,请使用函数get_the_excerpt()
。
如果您遇到HTML无法正确解码的问题,请使用wp_specialchars_decode
。以下是您可以实现的选项:
过滤器the_excerpt
,将此代码放入functions.php
中
add_filter( 'the_excerpt', 'wpse221201_get_the_excerpt', 1, 1 );
function wpse221201_get_the_excerpt( $content )
{
if ( ! is_admin() )
return wp_specialchars_decode( $content );
return $content;
}
echo wp_specialchars_decode( get_the_excerpt() );
p
标签的自动包裹功能...如果没有,也有一些插件可以帮你实现这个功能。- https://davidwalsh.name/disable-autop - Paulie_D