-1

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

1 Answers1

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