How about something like this instead:
add_action('template_redirect', function(){
get_header();
echo 'page stuff';
get_footer();
exit();
});
add_filter('the_title', function(){ return "Virtual Page Title"; });
What you are trying to do strikes me as very prone to error. Different themes can do all kinds of different things with page.php
, not to mention that it may not be present at all.
What you are doing actually works when I test it on Twenty Thirteen. If you are have trouble with some theme or another, take that as evidence of the preceding point– this strikes me as prone to error. A lot of things happen in themes that your plugin has no control over. If you are going to create a page you probably need to create the bulk of it yourself.
Related Posts:
- Pass PHP variable to javascript
- Is it possible to define a template for a custom post type within a plugin independent of the active theme?
- Ways to have multiple front-page.php templates that can be swapped out?
- Template for custom post type shows all posts instead of just one
- (FES EDD) New vendor submission page is blank
- Calling the_excerpt from inside a plugin template file
- Where to find the code used to render a page that has a shortcode and a template defined?
- Get post content from outside the loop with plugin shortcode usability
- Custom form not showing in correct place on page
- Price comparison table based on Custom Post Type?
- Pass PHP variable to javascript
- History of page, interval of years
- How to display content depending on the Woocommerce Product Category
- Creating a default Custom Post Template that a Theme can override
- WooCommerce – Load Templates From Plugin For All Template Files
- Best way to manage a lot of pages in Wp Admin [closed]
- Define Function in functions.php or plugin and call in theme loop
- posts page – different lengths of excerpt
- How can I add a custom header to a custom template in a plugin without using the theme folders
- Pages with 2 Columns
- Template plugin for blog posts? [closed]
- Custom url structure for custom template
- Developer plugin to echo template names/filepaths [closed]
- How does WordPress ensure plugins run at the same time and how does it solve a plugin’s dependency on another one?
- do_shortcode() doesn’t work if shortcode contained in variable, works if shortcode passed as string
- Is there a way to lock certain pages from being edited by anyone other then the admin?
- Replace existing pages with new pages, keep menu links
- How to show category images (from plugin) on a regular page (page-example.php)?
- [Plugin: Posts 2 Posts] How does it work?
- taxonomy_template filter do not loads custom taxonomy template properly
- Override comments.php template with plugin
- How can plugins have their own pages?
- wordpress reusable content blocks
- Add a plugin before main container
- Woocommerce email template customization [closed]
- wp alchemy multiple image uploader output images to template
- Can we use a webservice with WordPress?
- Register Page Template from Plugin
- Use wordpress functions in another PHP file
- WordPress web pages keep getting deleted (moved into the trash) by themselves
- Fetch Children of Grouped Products Inside WooCommerce Product Loop
- Run plugins only on certain pages
- WordPress plugin/theme or other wayout to create portable pages?
- Use of Templates in a Plugin
- Changing page URL and connect newsletter to MailChip
- Problem with the Loop – want to limit the access to three free articles
- How do I write an inventory list plugin that creates dynamic details pages?
- Can I allow certain people to add/edit pages within a parent?
- How do I make a variable available inside partials?
- Template filter for custom taxonomy terms
- how to force tag page layout to use same as search layout?
- WordPress Plugin manipulate have_posts()
- Recent posts per category loop?
- Bulk update wordpress posts
- WordPress as template engine
- Thesis 2 custom Page
- Default taxonomy template in plugin, override in theme
- Simulating a wp page – wp page load sequence
- Opening a JQuery modal window on click of a button with a JQuery plugin
- Huge number of 404 pages getting spawned
- Use jQuery Datepicker code from plugin
- How do I show content from a plugin using the template the site is currently working with?
- How to force load a page in plugin?
- How do i create a list-posts-page?
- Add custom PHP and HTML to the_content()
- How to modify the Loop from a plugin (instead of a theme)
- Is there a syntax highlighting plugin for HTML View? [duplicate]
- Gantry Framework: new page loads homepage content instead of page content
- use EDD Content Restriction for restricting php in template
- How to permanently show Word Counter on Create/Edit Page. WordPress5.9.3
- 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?
- Copy/paste local images not working in WordPress
- how to display a template.php in a shortcode
- Elementor: How to design Dropdown Select Box Navigation page like Chegg
- the_posts_pagination() not working if I add wp_head() to header.php
- What plugin would make this happen? If is the theme
- Automatic chage password of pages after some time
- How to allow URL with filename & extension in wordpress?
- Python in WordPress – A “Hello World” implementation
- Options page textarea to populate custom post select field
- Best way to create member pages for a lab website? [closed]
- Restrict my pages from public
- Displaying image from a repeatable group
- Advanced Custom Fields (ACF) Plugin – Random Image in Sidebar
- ‘all’ hook and add_action issue (class based plugin)
- How to set different users for different pages?
- Redirect url in plugin to somewhere else?
- How do i use postMash to order posts in a custom loop?
- Redirecting posts in WordPress to a specific page
- Getting Post Permalink Outside of Loop Not Working
- Trying to display posts but getting the pages as output
- 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
- How to dispaly post informations (such as titles) in an admin plugin menu page?
- Attachement title in wpallimport
- WordPress Plugin and other pages not opening
- FacetWP custom display based on post type [closed]
- Set the Social Icon Size in footer