2013-10-07 46 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 *

相關問題