如何用css中的另一个角色替换角色?

时间:2016-03-20 11:52:13

标签: html css wordpress

我想用帮助css显示一个带有另一个角色的角色。在我的页面wordpress中,我有一个这样的代码:

</span>
                <span class="address-place">
                 <?php echo the_excerpt (); ?>
                 <hr>
            </span>

此代码显示以下行:

  

&LT; p&gt; SE Portland的成人护理院雇佣一名住家照顾者;必须   说英语,能够履行工作职责......

我想替换&lt; p>与另一个角色,如css中没有任何东西或其他东西?我不需要在我的描述中显示该字符,我想在css中隐藏他,因为我的编辑页面生成&lt; p>标签

在网站上显示图片: enter image description here

由于

2 个答案:

答案 0 :(得分:4)

CSS无法操纵文字;它纯粹是一种用于样式化内容的语言。

但是你正在使用PHP - 首先只需要你想要的PHP输出。

<?php echo str_replace('p>', 'whatever>', get_the_excerpt()); ?>

答案 1 :(得分:1)

函数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() );
相关问题