As a wp plugin developer, I want to load a post single page from my plugin directory. Not a custom post type I want to load from the default wp post type.function.php template.php
Asked
Active
Viewed 58 times
-1
-
try this solution https://stackoverflow.com/questions/72438987/trying-to-add-a-custom-post-type-page-template-from-plugin-into-sage-10-theme/72442671#72442671 – Abdul Hanan May 31 '22 at 05:37
-
Already I tried it. But not working. – FERDAUS 01 May 31 '22 at 05:39
-
Please provide enough code so others can better understand or reproduce the problem. – Community May 31 '22 at 10:42
1 Answers
0
You can use this hook to check if this is a single page and the post type is 'post'
add_action( 'single_template', [$this, 'event_single_page'] );
function event_single_page( $single ) {
global $post;
if ( $post->post_type == 'post' && is_singular( 'post' ) ) {
$plugin_template = 'post-single-page.php';
if ( file_exists( $plugin_template ) ) {
$single = $plugin_template ;
}
}
return $single;
}

Reza Khan
- 86
- 3