WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use wp_enqueue_style to add my stylesheet, like this:

<?php wp_enqueue_style( 'theme-style', get_template_directory_uri() . '/style.php', false, '1.0', 'all' ); ?>

It works fine BUT I need to run a Wordpress function in the style.php file. The stylesheet file does not know that the core exists.

This is what I've heard

  • It's bad to include wp-load.php.
  • It's bad to include the stylesheet directly to header.php because plugins can't find it.
  • It's bad to include the stylesheet directly to wp_head functions because plugins can't find it.

Is there a "correct" way to do this?

share|improve this question
to run a wordpress function you will need to load wp-load.php which is not a good idea. If you can please explain more why you need to run a wordpress function some here might suggest you better alternative. – Hameedullah Khan Oct 11 '11 at 8:44
I have a plugin that echos CSS-files in the style.php and at the same time saves them as a cached file. Depending on if I'm on localhost or not it uses the PHP-file or the cached CSS-file. – Jens Törnell Oct 11 '11 at 10:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.