get_page_template()
can be overridden via the page_template
filter. If your plugin is a directory with the templates as files in them, it’s just a matter of passing the names of these files. If you want to create them “on the fly” (edit them in the admin area and save them in the database?), you might want to write them to a cache directory and refer to them, or hook into template_redirect
and do some crazy eval()
stuff.
A simple example for a plugin that “redirects” to a file in the same plugin directory if a certain criterium is true:
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;
}
Related Posts:
- 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?
- Template plugin for blog posts? [closed]
- Register Page Template from Plugin
- Plugin-generated pages use Not Found or Pages Archive templates?
- How to use get_template part in the plugin?
- Custom form not showing in correct place on page
- Ajax Call in page theme not working?
- How do I show content from a plugin using the template the site is currently working with?
- Pull comments from one page/post into another page/post?
- How to provide page_template path in custom plugin using WordPress
- Pass PHP variable to javascript
- Consuming an external API in WordPress?
- Creating a default Custom Post Template that a Theme can override
- WooCommerce – Load Templates From Plugin For All Template Files
- Add Archive Page Template via Plugin
- How can I add a custom header to a custom template in a plugin without using the theme folders
- Why am I sometimes getting a 404 error when I try to update a page with Elementor?
- Custom url structure for custom template
- Developer plugin to echo template names/filepaths [closed]
- How do I make a wordpress plugin with menu item etc
- do_shortcode() doesn’t work if shortcode contained in variable, works if shortcode passed as string
- Get image URL from media library in input
- Adding a post shortcode to a page template?
- taxonomy_template filter do not loads custom taxonomy template properly
- Plugin shortcode won’t work on a custom template file [closed]
- Override comments.php template with plugin
- How to enqueue a theme style-sheet to my admin settings page?
- Woocommerce email template customization [closed]
- How to get the HTML until ?
- More than one text-domain is being used because of the included templates for plugins
- Is there any way to get all the name or slug of template parts used in a page?
- Calling custom plugin class methods from a template
- Create a custom page template inside my wordpress plugin
- Can we use a webservice with WordPress?
- Should I fetch the data managed by a plugin by using its APIs or WordPress APIs?
- WP Post Template – Templates in own folder
- List Category Posts rewrite necessitates rewrite of customised templates
- (FES EDD) New vendor submission page is blank
- Facebook Messager Plugin
- Use of Templates in a Plugin
- Add comments for template variables
- Render custom php template into string
- Template filter for custom taxonomy terms
- how to force tag page layout to use same as search layout?
- Calling the_excerpt from inside a plugin template file
- Best practice for including plugin output in a template without using shortcode?
- WordPress as template engine
- Default taxonomy template in plugin, override in theme
- Trying to add a page template for my custom post type from a plugin, but it will not display in the template dropdown unless file is in theme
- Plugin Admin Menu Boiler Plate
- Opening a JQuery modal window on click of a button with a JQuery plugin
- How do I create a custom permalink structure for a page template
- Plugin create pages and use templates
- Pagination shows Same posts
- Should meta boxes for specific pages be save in their own plugins?
- reCAPTCHA on page template without plugin
- Woocommerce – Change Variable Product Add to Cart to behave like external product using Custom Field (link) [closed]
- How can recognize post’s category?
- Add custom PHP and HTML to the_content()
- How to modify the Loop from a plugin (instead of a theme)
- Multiple Post Thumbnails Plugin – Need help with code
- Show Homepage (only) Hits Count
- Wp-minify doesn’t seem to minify my JS code
- use EDD Content Restriction for restricting php in template
- Pass PHP variable to javascript
- How to makes changes on the shop/category/tag pages but not on the product pages in woocommerce?
- How can I disable an attribute from a Gutenberg block included in a template via InnerBlocks?
- How to turn my WordPress site into a ready to deploy template?
- how to display a template.php in a shortcode
- Enqueue css to a third-party plugin template
- the_posts_pagination() not working if I add wp_head() to header.php
- How to check if short code is present in template?
- How to add post title to custom php?
- How to access Post Archive created by Elementor?
- Programmatically generate new pages for a site based on page template and content elements accessed via DB
- WordPress Product Detail and catalog
- how do i fixe Page Builder on a custom page?
- How to change the deafult template in WordPress plugin
- Plugin json page
- Customize plugin templates
- WordPress arrows dissapeared strange signs
- How to use custom footer template in a site-plugin?
- Why is WP template_include overwritting all templates rather than specified page?
- How to differently style pages that display posts of different category in WordPress?
- Convert HTML5/CSS3 site to WordPress Theme (need a lot of plugins) or just use the API?
- show Visual form builder in the front end
- Fake Single WordPress Post (Page) Loop
- How to create a page template using custom plugin
- Make a Custom template for a specific category in wordpress
- WP Customer Reviews call short code on another page [closed]
- WordPress show different custom post type
- Display HTML5 jQuery Audio Player On Front Page
- Template library for WordPress [closed]
- How to display content depending on the Woocommerce Product Category
- Resources for building a custom event page template
- Is there a plugin or another way that can help me find out the underlying files of a page/post? [closed]
- How to make a Template page to show the information of different things Shop and Product page?
- Cannot register a block in my Twig-based theme using Timber for WP