2016-09-29 77 views
1

如何通過Wordpress 插件添加分類模板。它需要針對特定​​的類別。所以如果這個類別是'category-awesome'load'category-awesome.php'。我遇到使用單一模板鉤e.g:使用插件將特定分類頁面模板添加到WordPress

add_filter('single_template', 'my_custom_template'); 

但還沒有找到類別或單一類別什麼。

很多謝謝

回答

1

想我解決了它。使用template include filter hook

function category_awesome($template) { 

    if (is_category('awesome')) { 
    $new_template = dirname(__FILE__) . '/custom-template-awesome.php'; 
     if ('' != $new_template) { 
     return $new_template ; 
     } 
    } 

    return $template; 
} 

add_filter('template_include', 'category_awesome'); 
相關問題