2013-01-03 174 views
1

誰能告訴我如何使用add_filter函數來實現頁面的plugin_dir_path?Wordpress add_filter自定義內容

當我使用get_post_type()爲我的movie_reviews設置寺廟沒有問題 但我不知道如何使用none register_post_type函數。

我喜歡在URL中使用自定義頁面www.domain.com/user_profile 和形式行動對行動=「search_result」 但我不知道這是如何工作的一個沒有register_post_type

add_filter('template_include','include_template_function', 1); 

function include_template_function($template_path) { 

    if (get_post_type() == 'movie_reviews') { 
     $template_path = plugin_dir_path(__FILE__) .'/single-movie_reviews.php'; 
    } 
    if (....... == 'search_sesult') { 
     $template_path = plugin_dir_path(__FILE__) .'/movie-searchresult_reviews.php'; 
    } 
    if (....... == 'user_profile') { 
     $template_path = plugin_dir_path(__FILE__) .'/user_profile.php'; 
    } 


    return $template_path; 
} 

回答

0

您可以使用Conditional Tags

例如:

add_filter('template_include','include_template_function', 1); 

function include_template_function($template_path) { 

    if(is_search()) 
     $template_path = plugin_dir_path(__FILE__) .'/movie-searchresult_reviews.php'; 

    if(is_author()) 
     $template_path = plugin_dir_path(__FILE__) .'/user_profile.php'; 


    return $template_path; 
} 
相關問題