WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 want to know how to access the comments on the top of a style sheet with php , like the way wordpress does.

If we create a new theme for wordpress than we have to enter our name , blog name and some other parameter in the style sheet under comments and wordpress access those commments and show them as your theme information.

So does anyone have any idea how to do it.

Thank You

share|improve this question

Have a look in /wp-includes/functions.php at get_file_data(), this is the function that pulls the data out of style.css, called from the get_theme_data() function in /wp-includes/theme.php.

share|improve this answer

This is adapted from how WordPress does it:

$default_headers = array(
    'Name' => 'Theme Name',
    'URI' => 'Theme URI',

$theme_data = get_file_data('some-file.php', $default_headers);

The get_file_data() function will search the specified file for the values in $default_headers ('Theme Name' and 'Theme URI'), and returns an array with the same keys as $default_headers, with the parsed values.

share|improve this answer

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.