Get Template Name automatically like WordPress Does

I have used WordPress for sometime. One feature I really like is when you create a custom template and they automatically gets the Template Name in the Admin.

I’ am making my own Custom PHP CMS and would like this type of feature in my CMS too. But I’ am totally not sure how to do this in PHP.

Read More

Anyone has any ideas, Please do share?

Related posts

Leave a Reply

2 comments

  1. Investigate the WP_Theme class, located here. This is a relevant portion from the get_page_templates function:

    foreach ( $files as $file => $full_path ) {
        if ( ! preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path ), $header ) )
            continue;
        // do stuff
    }
    
  2. This may be useful as you decide how to name and visually represent different themes.

    The Theme’s name is set in the opening remarks in the style.css file in each Theme folder. That name appears when viewing the installed Themes the WP admin,

    /**
    * Theme Name: My Theme

    And the thumbnail that appears along with the Theme name is named “screenshot.png” and is also placed in the theme folder.