Support » Plugins » Hacks » How to create a custom template with plugin?

  • Resolved Sk Nepal


    I had coded a custom template and uploaded it to my theme’s directory. I would like to give the users ability to use that template without having to upload the file to their theme directory. I googled and found something that supposedly, did what I was looking for.

    add_filter( 'page_template', 'wpa3396_page_template' );
    function wpa3396_page_template( $page_template )
        if ( is_page( 'my-custom-page-slug' ) ) {
            $page_template = dirname( __FILE__ ) . '/custom-page-template.php';
        return $page_template;

    Basically, I would include the custom-page-template.php with in my plugins folder. Then whenever a particular page is opened (i.e., the page would use the custom-page-template.php as its template. How can I make the above code work? I just want to include the custom template in my plugin folder and make a particular page use that template. Please help.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to create a custom template with plugin?’ is closed to new replies.