Hello guys, recently i have needed to add a custom page template for a WordPress site by using plugins. So, when you active this plugins, for a specific page your custom template will be parse, unlike regular theme page template/layout.
For my case it was needed as because i wanted to remove the current activated theme’s header and footer. If you need this things to be done the following code sniped will be help you.
add_filter( 'page_template', 'your_custom_funtion_name' );
function your_custom_funtion_name( $page_template )
{
if ( is_page( 'your-specific-page-slug' ) ) {
$page_template = dirname( __FILE__ ) . '/your-custom-page-template.php';
}
return $page_template;
}
<html>
<head>
<title>Custom template</title>
</head>
<body>
<h1>Custom page template</h1>
</body>
</html>
if you follow this steps properly then, when you visit page with slug “your-specific-page-slug” you can see your custom page layout which is in “your-custom-page-template.php” file.