2013-10-07 16 views

回答

1

您可以使用跨到逗号或符号从文本的其余部分分离

<p> Some text <span style="color:pink">/</span> Some text ....</p>

我不认为是还不可能只用CSS

在PHP中你可以你的主题用了preg_replace文字周围添加逗号,连字符,斜线跨度等

http://php.net/manual/en/function.preg-replace.php

或str_replace函数

<?php str_replace(',', '<span class="pink">,</span>', $string); ?> 

为WordPress建议的代码添加到您的模板文件,以获得更多信息有关模板化看: http://codex.wordpress.org/Stepping_Into_Templates

+0

我想这样做没有类,跨度等,只有与CSS。 – Blanka

+0

而你不想使用PHP来使它工作? – Kentoro

+0

@布兰卡,你根本无法单独使用CSS来做到这一点。您需要在元素中手动或服务器端或客户端包装字符。 –

0

该做的事:

add_filter('the_content', 'testfilter'); 

function testfilter($content) { 

    $pattern = ' | '; //search content for ' | ' string 
    $replacement = '<span class="test">' . $pattern . '</span>'; //replace it with the same term but inside a span 
    $replaced = str_replace($pattern, $replacement, $content); 
    return $replaced; 

} 

积分去这里: * http://wordpress.org/support/topic/str_replace-content-with-a-span-class *

相关问题