PHP stylesheet cannot use standard WP functions

If you’re linking to a file, it’s opened as a new file. So unless you explicitly include wp_load.php or something within that styles file, WordPress is not available.

Loading WP all over again in one page load seems like complete overkill to me. Why don’t you just include your style file as an inline stylesheet, if you need to use WP engine?

Do something like this:

<style>
<?php include_once('styles.php'); ?>
</style>

Leave a Comment