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 am trying to get the path to the themes CSS file from inside a Plugin, anyone know how to do this?

share|improve this question
up vote 2 down vote accepted

Get the absolute path: get_stylesheet_directory()

Get the URI: get_stylesheet_directory_uri()

Edit: Here's a proof of concept plugin. It will just print out the stylesheet path and uri in the head tag of your site (front end). If these functions are not working in your plugin, there might be some other factor not explained in the OP. Please post your code.

 * Plugin Name: Get Style Sheet Test
 * Plugin URI: 
 * Description: Demonstration of get_stylesheet_directory() and get_stylesheet_directory_uri() within a plugin.
 * Version: 1.0
 * Author: goto10
 * Author URI: 
 * License: 

add_action( 'wp_head', 'get_stylesheet_dir_and_uri_test' );

function get_stylesheet_dir_and_uri_test() {
    $output = "<!-- \nGet the absolute path using get_stylesheet_directory(): " . get_stylesheet_directory() . "\n";
    $output .= "Get the URI using get_stylesheet_directory_uri(): " . get_stylesheet_directory_uri() . "\n -->";
    echo $output;
share|improve this answer
Hello that is what I thought would work however when used in a plugin file I get Fatal error: Call to undefined function get_stylesheet_directory() so the plugin file doesn't have access to the file containing that function, any ideas for a fix – JasonDavis Dec 10 '11 at 10:37
Hrmm, not sure. Added example plugin. Can you post your code? – goto10 Dec 11 '11 at 0:24

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.