After trying a whole bunch of filter possibilities, I found one that worked.
add_filter( 'single_template', array($this,'page_template') );
Which got my function to be called. However, I also needed to make some more changes (not least of which taking out the die
line). This was, finally, what worked:
public function page_template( $page_template ) {
global $post;
if ( 'my_lovely_post_type' === $post->post_type ) {
$page_template = BUSINESS_PAGE_PLUGIN_DIR . 'templates/business-page.php';
}
return $page_template;
}
Related Posts:
- Looking for WordPress System Diagrams
- How can I load a page template from a plugin?
- Overwrite theme file from plugin
- How to control output of custom post type without modifying theme?
- When is it appropriate to put functions on page template vs. functions.php?
- Filter to change the content of 404 page
- How to properly use a hook to create template for custom product type in a plugin such as Woocommerce? [closed]
- How to check active theme is parent or child wordpress
- WordPress removing data attributes for scheduled post
- Is there a way to loop through a shortcode datasource to create a table?
- creating custom archive template within plugin for custom post type using archive_template filter
- Where to call wp_enqueue_script in a plugin with custom template?
- Can Page Templates be Applied to Archive and Post Templates?
- ORDER BY wp_post custom column name in wp_query
- Create a free scripts and styles template within a plugin
- How can I turn a custom wordpress page into a product page?
- Plugin templates vs Parent Theme
- How to make “upgrade safe” theme for a plugin?
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- How to create templates for a custom module to show on the front end within my theme?
- Why aren’t some plugin styles loading when I load a template?
- Plugin custom post template; without overriding all posts
- Best way to distribute templates and code accross multiple wordpress sites?
- Load php file with jquery in single.php
- Overriding the template files using a plugin for all themes
- Javascript not being loaded only in custom taxonomy template
- Add new header/footer on landing page with plugin
- Use a page as a template for a custom post type
- Page template compatibility with different themes
- How to set custom homepage via a plugin
- Template file structure , wordpress hook for altering the template
- Displaying External Data – Not Posts
- Making plugin output customizable
- Use different archive template for plugin
- How to display custom taxonomy and terms using/creating plugin template
- How to check during “pre_get_posts” if WP performing default query for specific custom template?
- WP Job Manager – Show recent jobs as cards
- Help interpreting @wordpress/create-block-tutorial-template usage error
- How to get the path to the current theme?
- Post meta vs separate database tables
- Inserting Taxonomy Terms During a Plugin Activation?
- Replace audio/video enclosure with player?
- How do you use the plugin boilerplate loader class to hook actions and filters?
- Contact Form 7: wp_mail doesn’t work after update to 4.6
- Gutenberg ServerSideRender is deprecated, how to work with new wp.serverSideRender component?
- Turn revisions off in plugin instead of config.php?
- Add an image gallery to a custom post type?
- Unit testing wordpress plugins with plugin options
- Script to remove all inactive widgets?
- Disable $title in Plugin Options Screen?
- WordPress Localization and Templating
- Why after a file is programmatically deleted, is there still a reference in the media library?
- My new WordPress plugin version is not showing up in the plugin directory. It’s been 4 days what could the problem be?
- Synchronize Custom post type tags to WordPress default posts tags
- Tabbed navigation for plugin options using same row in database for all?
- Ethics question: what qualifies as a fork? [closed]
- How can I prevent my plugin’s next version from updating one of the files?
- How to i18n text coming from the db or from an external source
- Sending post request with wp_remote_post not working correctly
- Input value from metabox is not found in $_POST after post save
- CMB2 Form Throws No Input File Specified in custom WordPress Plugin
- Enqueue script globally
- White screen when activating plugin that sends form via WordPress
- Custom entity search and display
- Plugin README.txt isn’t updating in the Directory (stable tag is correct)
- post_title is empty on global $post object
- Can woocommerse be used dynamically for billing from another plugin for payment processing?
- Mock a dependency of a WP_REST_Controller class
- Remove All Taxonomies from Post On Update
- Plugin index page code executes multiple times
- add_action pre_term_description vs. pre_category_description
- WordPress Plugin Development- When our plugin functions call?
- WordPress Plugin Authoring question about jquery and css
- How to create archive page to add in menu
- Query String Filtering API
- Get Custom taxonomy parent with wordpress REST API
- What to do with the .git folder in a WordPress plugin during local development
- I’m including a html file in my plugin, but it can’t find its css or js files
- ajax-action.php can’t find added action
- woocommerce add a new bulk action in the bulk actions dropdown in the orders list
- Ajax Response Error | just getting error as the response
- Building WordPress Themes With Bootstrap with Adi Purdila → TutsPlus
- Need to change buddypress profile url by add_rewrite_rule
- Generate activation url
- Settings API not Saving to Database or Display
- Error using @wordpress/create-block to create multiple blocks on Windows
- How to create a database table in WordPress using PHP
- Render raw html in Gutenberg block
- How can I create a custom plugin to call webapi after user registration?
- Displaying an Uploaded Image as a Custom Avatar in WordPress
- Rest Api WordPress
- How to create A – Z List with pictures?
- How do I display and edit other posts within the ‘Edit Post’ area of Wp-Admin Dashboard
- A better way of getting draft posts that has a particular post meta using get_posts function
- Save translation file of third party plugin in a custom plugin?
- Custom rewrite, url path with parameters to a page
- Developing an IP lookup function using an API
- Making a user platform reachable by a qr code on a pin-back-button [closed]
- how to add contact form 7 shortcode in javascript variable
- select rows based on exact time (hours, minutes and seconds)