[wp-hackers] Dynamic Style Sheets

Jamie Talbot wphackers at jamietalbot.com
Sun Apr 29 08:10:35 GMT 2007

Computer Guru wrote:
> Matt wrote:
> if (is_single()) {
> ....
> echo  '<link rel="stylesheet" href="mycss.php?test_pass" />';
> }
> ?>
> You know, basically do all your testing in the WP php, then pass
> whatever info you need to the CSS file as arguments at the end.

I think he said he didn't want to do it this way?

You could hook the_content() maybe?

// Counts the number of paragraphs, adds a class to each paragraph, depending on the number.
function my_content($content) {
	$count = get_number_of_paragraphs();
	return preg_replace('<p>', "<p class=\"para_class_$count\">", $content);

add_filter('the_content', 'my_content');

Alternatively, instead of adding a class to each paragraph, you could just wrap the whole content in
a div with a class.




More information about the wp-hackers mailing list