For example I want to have all commas ( or whatever other characters like this: " /, |, &, $
and so on " ) from a text in different colors.
Is this possible?!
You could use spans to separate the commas or ampersand from the rest of the text
<p> Some text <span style="color:pink">/</span> Some text ....</p>
I don't think is yet possible using only css
In PHP you could theme your text with preg_replace to add the spans around the comma, ampersand, slash, etc.
http://php.net/manual/en/function.preg-replace.php
or str_replace
<?php str_replace(',', '<span class="pink">,</span>', $string); ?>
For wordpress add the suggested code to your template file, for more info about templating see: http://codex.wordpress.org/Stepping_Into_Templates
This do the thing:
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;
}
Credits goes here: * http://wordpress.org/support/topic/str_replace-content-with-a-span-class *
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.