1

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

1

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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