最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - White page by using filter template_include

programmeradmin2浏览0评论

I working on my plugin and tried to override some templates.

If I visit the page portfolio my screen gives a whitepage.

This is my code

define("PLUGIN_DIR_PATH", plugin_dir_path(__FILE__));
add_filter( 'template_include', 'plugin_tweak_template', 99);

function plugin_tweak_template( $template ) {
    if ( is_page('portfolio')) {
        $template = PLUGIN_DIR_PATH . 'required/templates/portfolio.php';
    }
    return $template;
}

I use this code in my plugin root file.

I working on my plugin and tried to override some templates.

If I visit the page portfolio my screen gives a whitepage.

This is my code

define("PLUGIN_DIR_PATH", plugin_dir_path(__FILE__));
add_filter( 'template_include', 'plugin_tweak_template', 99);

function plugin_tweak_template( $template ) {
    if ( is_page('portfolio')) {
        $template = PLUGIN_DIR_PATH . 'required/templates/portfolio.php';
    }
    return $template;
}

I use this code in my plugin root file.

Share Improve this question asked Apr 14, 2020 at 21:59 SebasSebas 132 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The white screen means that you have a critical error that is halting execution, but you do not have PHP messaging turned on to tell you what that error is.

Turn on debug mode in WordPress so the error message is displayed. Otherwise you don't have enough information to correct your problem. Set the WP_DEBUG constant in your wp-config.php file to true. See: Debugging in WordPress

Once you know what that error is, you can edit your question with more information.

发布评论

评论列表(0)

  1. 暂无评论