2

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?

2
  • 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. Commented Oct 11, 2011 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. Commented Oct 11, 2011 at 10:16

1 Answer 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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