admin管理员组

文章数量:1387323

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.

本文标签: pluginsWhite page by using filter templateinclude