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
- List Category Posts rewrite necessitates rewrite of customised templates
- WordPress comments not appearing in blog posts, likely because of Redux template. Could I fix this with a plugin that adds a comment form as a block? [closed]
- How to delete page by deactivating plugin
- 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
- Plugin-generated pages use Not Found or Pages Archive templates?
- How to display (plugin?) output on a single page (not a widget, probably not a short code) – template, plugin, combination?
- Facebook Messager Plugin
- Advanced Custom Field DatePicker [closed]
- WordPress plugin/theme or other wayout to create portable pages?
- Use of Templates in a Plugin
- Insert content of a post into another
- Add comments for template variables
- php page not found for plugin options menu
- Changing page URL and connect newsletter to MailChip
- Problem with the Loop – want to limit the access to three free articles
- WordPress page and plugin list using sql query
- Create page from plugin, but have it completely hidden
- Render custom php template into string
- Perform internal redirect in WordPress?
- How WordPress is able to change locale without using setlocale
- How to add subcategories to the blogroll?
- 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?
- Proper way to replace the_content only for pages created by custom plugin
- Add menu page issues (permissions & position)
- Is there any hook for theme activation ? or something similar?
- How to use get_template part in the plugin?
- changing posts layout in ultimate member profile plugin
- How do I make a variable available inside partials?
- Template filter for custom taxonomy terms
- Display Custom Field Value on Admin Page Column
- How to insert category list into post creation page, and retrieve chosen categories?
- Would Gutenberg be considered a PlugIn?
- I need help locating a URL that is on my site map, but that I can’t find in my WordPress dashboard
- how to force tag page layout to use same as search layout?
- WordPress Plugin manipulate have_posts()
- Show author on every sub-page
- Get User_id outside wordpress,
- How can I use a file in my plugin as a replacement for single.php on custom-post-type query?
- Recent posts per category loop?
- Best practice for including plugin output in a template without using shortcode?
- Timber – Twig post.content returns null can’t create ACF Gutenberg blocks
- Import Instagram post to WordPress blog post
- How to have sample page for each new register users in a membership website
- Bulk update wordpress posts
- How to get a list of bundled products using wp_query in woocommerce
- One sub site is slow while all others load fine, same theme & plugins [closed]
- How do I override plugin templates and stylesheets?
- How to create a page with links to other pages that include image and excerpt?
- WordPress as template engine
- Thesis 2 custom Page
- Making my plugin create a page?
- Default taxonomy template in plugin, override in theme
- Add Content to Content()
- Simulating a wp page – wp page load sequence
- Plugin Admin Menu Boiler Plate
- Loop in elementor custom widget not working
- get_users(); Is an Undefined Function When Used in Cron Job
- Opening a JQuery modal window on click of a button with a JQuery plugin
- How to use template inside plugin shortcode with variables for big HTML code
- Trying to add_action in a loop
- How to create wordpress page that lets users create their own quiz? [closed]
- Loop returns the current page’s permalink and guid instead of the post in the loop
- Huge number of 404 pages getting spawned
- Pagination shows Same posts
- How to create plugin auto create page wordpress?
- Change website directory safely to add a static page on startup
- Should meta boxes for specific pages be save in their own plugins?
- Call a function for social sharing
- Show related posts based of current ACF field name in a single page post (a loop within loop)
- Ajax Call in page theme not working?
- Remember the Meta Value With Radio Buttons
- Use jQuery Datepicker code from plugin
- reCAPTCHA on page template without plugin
- How do I show content from a plugin using the template the site is currently working with?
- Woocommerce – Change Variable Product Add to Cart to behave like external product using Custom Field (link) [closed]
- Prevent plug-in scripts on a specific template?
- Output after specific post in the loop
- How to force load a page in plugin?
- How to dynamically change spots of text in custom page?
- Plugin is creating posts twice
- Polldaddy doesn’t show up on own theme
- How do i create a list-posts-page?
- Pull comments from one page/post into another page/post?
- Add custom PHP and HTML to the_content()