You misunderstand what page_template does. It does not create a new template that you will “show up” somewhere and that you can use. It replaces the page.php template provided by the theme.
I think that what you want is template_redirect:
function custom_page_template( $page_template ) {
if (is_home()) {
get_header();
echo 'do stuff';
get_footer();
}
}
add_filter( 'template_redirect', 'custom_page_template' );
Or template_include:
function custom_page_template( $page_template ) {
if (is_home()) {
$page_template = plugin_dir_path( __FILE__ ) . 'custom-page-template.php';
return $page_template;
}
}
add_filter( 'template_include', 'custom_page_template' );
Related Posts:
- Plugin-generated pages use Not Found or Pages Archive templates?
- How do I show content from a plugin using the template the site is currently working with?
- How to provide page_template path in custom plugin using WordPress
- Create custom page templates with plugins?
- Pass PHP variable to javascript
- Is there a WordPress plugin that registers a plugin file as a custom page template?
- Is it possible to stop selected plugins from loading on certain template pages?
- Ways to have multiple front-page.php templates that can be swapped out?
- Page Templates from plugin not working after upgrading WP to 4.7 or upper version
- Creating a default Custom Post Template that a Theme can override
- How can I add a custom header to a custom template in a plugin without using the theme folders
- Template plugin for blog posts? [closed]
- Custom url structure for custom template
- Is it possible to upload a template file to a directory that can be used by all themes?
- Get image URL from media library in input
- Override comments.php template with plugin
- Is there any way to get all the name or slug of template parts used in a page?
- Create a custom page template inside my wordpress plugin
- Can we use a webservice with WordPress?
- WP Post Template – Templates in own folder
- Perform internal redirect in WordPress?
- How to use get_template part in the plugin?
- how to force tag page layout to use same as search layout?
- Default taxonomy template in plugin, override in theme
- How to use template inside plugin shortcode with variables for big HTML code
- Plugin create pages and use templates
- Custom form not showing in correct place on page
- Ajax Call in page theme not working?
- Pull comments from one page/post into another page/post?
- Pass PHP variable to javascript
- How to prevent redoing get_posts queries and make results available to other scripts?
- how to do Thematic like this website using wordpress?
- WordPress Product Detail and catalog
- Plugin json page
- How to use custom footer template in a site-plugin?
- Custom Page Templates for a complex application – code must sit in a plugin and not the Theme
- show Visual form builder in the front end
- How to create a page template using custom plugin
- How to make a Template page to show the information of different things Shop and Product page?
- Does the number of downloads displayed for a plug-in in the WordPress.org plug-in directory include automatic updates?
- Which method is best to enqueue scripts
- Function to activate WordPress theme inside a plugin
- What is the correct way to check if WP_Filesystem can write to a directory without aking for username / password?
- Is there a WordPress Plugin that allows voting “does this coupon work” on specific links like Retailmenot
- Pass A Value From Outside To A Plugin Variable
- shortcode doesn’t work
- Built in admin ajax hooks?
- Force plugin to fail activation
- Could someone please help me to add category id with in this query so this will return posts from a certain category?
- What are the benefit in adding hook in the init() hook?
- building plugin and it is displaying above plugins page
- load_theme_textdomain path
- More than one text-domain is being used because of the included templates for plugins
- Dynamic CSS Vs Inline Issues in Code any Way around in a WordPress Themes?
- Is license need for free wordpress plugin
- plugin development: problem with functions
- Unable to override pluggable function wp_mail
- Avoid class name collision when using third party libraries in plugins?
- How to set taxonomy in custom plugin?
- Plugin development: Buggy plugin preview
- how to use in custom single.php template using php?
- Render custom php template into string
- Howto check version of another plugin and then add a submenu page to it
- Can a Plugin Override New User Default Role Type
- How to let user store a file in plugin directory but not have it get deleted on update?
- Great blogs site resources/tutorial for WordPress Developers? [closed]
- Plugins ignored a line breaks or tag in the WordPress comment functions
- Change letters for day name
- (WordPress 5.8.3) Function.php or a plugin for better performance? [duplicate]
- Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
- Elementor Custom Control: How to get input value?
- WordPress API functions not working at AJAX functions.php call
- How to check homepage contain blog post?
- Create “new pages” within the admin section of plugin
- More gentle way to hook WordPress custom url
- Creating a plugin that will display text on every page
- Xamp installed local wordpress not allowing to publish or install plugin
- How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?
- Using sessions or an alternative in a plugin
- Correct way to expand custom WordPress plugin functions
- adding dynamic/multiple slug values in ‘option_none_value’
- Update wordpress user roles not working as excepted
- is it possible to fetch data from a remote api while admin is writing a new post?
- Checkbox field that add a subscription product and change prices of other products in checkout and cart page
- Can’t access 3rd party API, code works on local server but not on wordpress
- Custom author page for custom role
- Storing Array of values into wordpress options
- Using WordPress to create a simple web app (SaaS) [closed]
- Front End Page Not Loading Header Footer
- Can plugin automatically update if i hide the update notification?
- Saving plugin data returns “You do not have sufficient permissions to access this page.”
- Apache rewrite rules and wordpress problem
- Active Plugins for current blog in WP Multisite Network? [duplicate]
- Many Field in Front End User Registration form insert as post
- how to set approval of admin for wordpress posts submitted by the user?
- WordPress Plugin Reviewer
- Plugin to display text before a post
- Get all the related data from WordPress DB
- Plugin to Display Content on Page
- WordPress s2 member plugin not working [closed]