wp-papi / papi

:rocket: WordPress Page Type API with custom fields
https://wp-papi.github.io
MIT License
263 stars 32 forks source link

Add filter to modify papi's custom template include function #263

Closed frozzare closed 5 years ago

frozzare commented 5 years ago

Example using Sage theme.

// Today
remove_filter('template_include', 'papi_template_include');
add_filter('template_include', function ($orginal) {
    $new = papi_template_include($orginal);

    if ($orginal === $new) {
        return $orginal;
    }

    echo template($new);
    return get_stylesheet_directory().'/index.php';
});

// After (example)
// $template = 'pages/video.php'
add_filter('papi_template_include', function ($orginal) {
    $new = papi_template_include($orginal);

    if ($orginal === $new) {
        return $orginal;
    }

    echo template($new);
    return get_stylesheet_directory().'/index.php';
} );
frozzare commented 5 years ago

Fixed by https://github.com/wp-papi/papi/commit/1655c1b78d2c8ac6a4074849e2b2fe79d9609a5c

frozzare commented 5 years ago
add_filter( 'papi/pre_template_include', function ($orginal) {
    return $orginal;
} );