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?
- Who are the most trusted plugin developers? [closed]
- Get plugin_dir_url() from one level deep within plugin
- Redirect to settings page after install
- How does WordPress determine the primary plugin PHP file?
- Adding Featured Image in Post List
- Should I use RIPS tool to test my themes and plugins?
- Add Top-Level Menu that opens URL
- flush_rewrite_rules() not working on plugin activation
- Determine plugin name from within plugin_action_links filter
- Plugin Functionality Only for Editor and Administrator
- Plugin to hide admin menu (vertical menu bar)
- Having separate plugins and themes folder for multi-site setup
- action-scheduler vs wp-background-processing
- Do you clean up your self-written plugins’ at deactivation?
- How do I turn a custom post type into a plugin?
- Add keywords meta to index.php page
- Private Plugin Updates – Localhost
- Any hook for pre-plugin-update -either bulk or single plugin update
- Making a plugin only available on the front-end for the logged in super admin
- When to load auto-login code?
- How can i change the texts of plugin (created by me) in wordpress admin?
- WordPress : Explain Plugins & Theme string value in database
- modify plugin to support RTL
- Calling the_excerpt from inside a plugin template file
- Can I use register_settings and unregister_setting once the settings page has loaded?
- Bulk update wordpress posts
- Plugin function inside custom plugin
- Is there a plugin for automatically adding a word or symbol after a trigger word? I.e. Like a search and replace but more like search and add? [closed]
- How to use add_action for multiple instances of the same class
- How can i listing current category and Featured Category post list?
- Ajax request sends url rather than data
- How to displaying Custom image, text and default image logo from Redux Framework option panel
- Grouping imported products and showing variations based on selected product
- save_post_product action not firing
- How to get the custom field value using SQL query
- specific rows style for in custom list table using WP_List_Table
- How to display the category name in the tab and post inside the tab in WordPress?
- How would I Redirect an existing WooCommerce customer to a specific url after Checkout
- Has blocks gutenberg block multiples registers type in my Plugin
- Ultimate Members Default Post Layout problem
- best way to upload a large file to wordpress using wp all import
- Why do actions with class and public method don’t fire __construct()
- How to define the slug for my custom plugin?
- Custom plugin settings page with tab. Error: “Sorry, you are not allowed to access this page.”
- return bbp_get_topic_author_id as integer
- How to add a box note in wordpress plugin page ? top header side.
- Widget outputs the value but doesn’t save anything inside the textarea
- WordPress Widget: Is it possible to make the form dynamic without updating?
- Why some plugins are including wp-includes/plugin.php file?
- Display_rows() and column_cb() strange behaviour
- WordPress plugin options need to delete after deactivate & uninstall
- How can I pass value to function in add_menu_page?
- Making a Custom Post Type Publish Loop
- The plugin generated xxx characters of unexpected output during activation
- How to hide a piece of code from a wordpress web page?
- How to dispaly post informations (such as titles) in an admin plugin menu page?
- Someone Comment 1000 times in a Day in My WordPress Site, What Can i Do
- Unable to pass arguments from plugin form to filter hook using ajax, the data is transferring via ajax but unable to pass as arguments in filter hooks
- How to update changes to multiple sites at the same time
- Why am I getting an error when requiring a file in my plugin?
- Running a function using Crown WordPress on one day a week, for example, Mondays of every week