[wp-hackers] Dynamic Style Sheets

Andy Skelton skeltoac at gmail.com
Sun Apr 29 06:32:53 GMT 2007

On 4/29/07, Guy Leech <guyleech at gmail.com> wrote:
> I simply modified the get_themes() function to include 'stlye.php' or '
> style.css'. Since the time of writing I've realised that I need to include
> 'wp-blog-header', and now everything is working fine and dandy. Though I'm
> still having trouble figuring out if the page I'm on is a single page, as
> the stylesheet can be called from anywhere. I'm sure I'll work something
> out.

Having your style.php call is_single() will never work. The request
for the HTML and the request for the CSS are distinct HTTP requests
and the server has no way to connect them.

You can add a dynamic stylesheet without hacking core files by using
the action hook wp_head. You can pass your dynamic stylesheet script
any kind of information via its URL query string.

But why would you do any of these things? A static stylesheet can
serve you just as well. Instead of changing the CSS to fit the WP
context, use the WP context to change the markup so that different ids
or classes trigger the presentational changes you want.

You might want to use the Sandbox theme over at http://plaintxt.org/
and save yourself a lot of time. :-)


More information about the wp-hackers mailing list