Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_category_template [ WordPress Function ]

get_category_template ( No parameters )
Uses:
Returns:
  • (string)
Defined at:



Retrieve path of category template in current or parent template.

Works by first retrieving the current slug for example 'category-default.php' and then trying category ID, for example 'category-1.php' and will finally fallback to category.php template, if those files don't exist.

Source


<?php
function get_category_template() {
    
$category get_queried_object();

    
$templates = array();

    
$templates[] = "category-{$category->slug}.php";
    
$templates[] = "category-{$category->term_id}.php";
    
$templates[] = 'category.php';

    return 
get_query_template'category'$templates );
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics