Created
January 30, 2014 11:42
-
-
Save kosinix/8706869 to your computer and use it in GitHub Desktop.
Learn what template you are in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function template_hierarchy_detector(){ | |
| $out = array(); | |
| if ( is_404() ) { | |
| $out[] = 'Error 404 Page'; | |
| } | |
| if( is_search() ){ | |
| $out[] = 'Search Result Page'; | |
| } | |
| if( is_archive() ){ | |
| $out[] = 'Archive Page'; | |
| if(is_tax()){ | |
| $out[] = 'Custom Taxo Archive'; | |
| } | |
| if(is_category()){ | |
| $out[] = 'Category Archive'; | |
| } | |
| if(is_tag()){ | |
| $out[] = 'Tag Archive'; | |
| } | |
| if(is_author()){ | |
| $out[] = 'Author Archive'; | |
| } | |
| if(is_date()){ | |
| $out[] = 'Date Archive'; | |
| if(is_year()){ | |
| $out[] = 'Year Archive'; | |
| } | |
| if(is_month()){ | |
| $out[] = 'Month Archive'; | |
| } | |
| if(is_day()){ | |
| $out[] = 'Day Archive'; | |
| } | |
| } | |
| if(is_post_type_archive()){ | |
| $out[] = 'Custom Post Archive'; | |
| } | |
| } | |
| if( is_singular() ){ | |
| $out[] = 'Singular Page'; | |
| if( is_singular('page') ){ | |
| $out[] = 'Static Page'; | |
| } else { | |
| $out[] = 'Single Post Page'; | |
| if(is_singular('attachment')){ | |
| $out[] = 'Attachment Post'; | |
| } else if(is_singular('post')){ | |
| $out[] = 'Blog Post'; | |
| } else { | |
| $out[] = 'Custom Post'; | |
| } | |
| } | |
| } | |
| if( is_front_page() ){ | |
| $out[] = 'Site Front Page'; | |
| } | |
| if( is_home() ){ | |
| $out[] = 'Blog Posts Index Page'; | |
| } | |
| if( is_comments_popup() ){ | |
| $out[] = 'Comments Popup Page'; | |
| } | |
| var_dump($out); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment