Wordpress: switch CSS stylesheets

It is possible to switch a theme’s CSS, depending on whether widgets are enabled or not - whether, like a lot of things in programming it is a good idea to do this, just because you can, is another matter…

This is the code - in the head section of header.php and after the main stylesheet of the theme, always style.css, has been linked to.

<?php if (function_exists(’dynamic_sidebar’)) { ?>

<link rel=”stylesheet” href=”<?php bloginfo(’stylesheet_directory’); ?>/widgets.css” type=”text/css” media=”screen” />

<?php } else { ?>

<link rel=”stylesheet” href=”<?php bloginfo(’stylesheet_directory’); ?>/nonwidgets.css” type=”text/css” media=”screen” />

<?php } ?>

But it does rely on the WordPress foible of not being able to switch widgets off completely (except by deleting code).

Far better is to struggle on with the XHTML/CSS until you get something that is the same for both and don’t need 2 stylesheets in the first place…

Bookmark:
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Google
  • Facebook
  • Furl
  • NewsVine
  • Reddit
  • StumbleUpon
  • Sphinn
  • Technorati

1 Comment

Pingbacks/Trackbacks

  1. élet és könyvtár » Blog Archive » Vasárnap reggeli WordPress és dizájn linkek

RSS feed for comments on this post. TrackBack URI

Leave a comment