Horje
How to Output which theme template file a post/page is using in the header

Method-1: Output which theme template file a post/page is using in the header

Just copy and paste following codes to yourdomain.com/wp-content/themes/activated-theme/fucntions.php in the most below.
Example: PHP
add_action('wp_head', 'show_template');
function show_template() {
    global $template;
    print_r($template);
}

then

Shorten the default DIV output if your theme is using post_class. If your theme is using something like
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

You can have crazy long divs in your source that might look like this or even longer:
<div id="post-4" class="post-4 post type-post hentry category-uncategorized category-test category-test-1-billion category-test2 category-test3 category-testing">

This can really start to clutter your source and seem rather unnecessary in most cases, going 3-4 deep is good enough. For the top example we can slice the output like so:
// Slice crazy long div outputs
function category_id_class($classes) {
    global $post;
    foreach((get_the_category($post->ID)) as $category)
        $classes[] = $category->category_nicename;
        return array_slice($classes, 0,5);
}
add_filter('post_class', 'category_id_class');

This slices the output to only include the first 5 values, so the above example becomes:
<div id="post-4" class="post-4 post type-post hentry category-uncategorized">





Related Articles
How to Output which theme template file a post/page is using in the header Wordpress Header Footer Shortcode

Single Articles
Method-1: Output which theme template file a post/page is using in the headerWordpress Header Footer Shortcode
thenWordpress Header Footer Shortcode

Read Full:
Wordpress Header Footer Shortcode
Category:
Web Tutorial
Sub Category:
Wordpress Header Footer Shortcode
Uploaded:
1 year ago
Uploaded by:
Admin
Views:
53



Share on: