The page_template
is a filter, not an action. Specifically it’s filtering the file path of the template to be included.
So really you shouldn’t be loading anything in that callback (it’s too early). Instead just return its file path.
add_filter( 'page_template', 'load_tq_templates' );
function load_tq_templates( $template ) {
if ( is_page( 'transport-quote-1' ) ) {
if ( $overridden_template = locate_template( 'tq-1.php' ) ) {
$template = $overridden_template;
} else {
// If neither the child nor parent theme have overridden the template,
// we load the template from the 'templates' sub-directory of the directory this file is in
$template = dirname( __FILE__ ) . '/templates/tq-1.php';
}
}
return $template;
}
Related Posts:
- How can I load a page template from a plugin?
- How can I add an option to the Page Template list from a Plugin?
- How to create custom home page via plugin?
- Dynamically override page.php or single.php with custom templates using function
- Is it possible for a plugin to register a page template file?
- Calling a function from functions.php in custom page/ blog post
- Build dynamic page from cURL (HTML page) response with plugin
- Load page template with custom content using a plugin
- How to Add Page Template from Plugin without Losing $this
- Dequeue theme stylesheets but keep widget styling on custom page template
- How to display non-page / post content
- Change template dynamically
- Problem with parameters in url and pagination
- Set page template programaticlly in plugin
- How can I pass get_the_author_meta(‘user_email’) through the REST API?
- Can Page Templates be Applied to Archive and Post Templates?
- Remove sidebar on single page using plugin API
- my basic php code producing unexpected results
- Create page (not the post type) dynamically
- How to output functions from plugin inside theme
- Best way to distribute templates and code accross multiple wordpress sites?
- How to remove/replace current page template?
- Load php file with jquery in single.php
- Conditionally check if page is using template from plugin directory
- How to save multiple values in custom post type from front end to back end
- Change Front page displays settings conditionally when user is online
- Can’t create a blank template
- Code to add template to page
- Page template compatibility with different themes
- Using a Page Template Not in Theme
- Find Any Theme’s page.php File
- REST API error in block editor for custom templates
- Generating Multiple Divi Pages from Database
- How can a plugin create a page/form in the front end?
- Looking for WordPress System Diagrams
- Init action hook running late after PayPal’s return url?
- Get specific color from admin color scheme
- How do you create a custom edit.php / edit pages page
- Check the Version of an Enqueue’d External Library
- Edit the output of wp_widget_rss_output()
- How to Parse an Array of Elements in Gutenberg Block
- Custom rewrite rule serves content, but returns 404 error code
- How to edit mySQL wp_posts table from plugin php?
- Creating a Wordpess Plugin that writes data to a csv file. The data doesn’t show in the csv file?
- WP_Query with tax_query, order by most ‘matches’
- Using the Settings API, how should I add multiple values to an option?
- WP custom menus error > menu name already exists?
- Problem with is_active_sidebar?
- How to sanitize user input?
- Remove Internal Style Sheet if no Value Provided?
- Widget update function not saving values
- get_the_excerpt() is not returning an empty string when the_excerpt is blank?
- “Plugin could not be activated because it triggered a fatal error.”
- Storing product price data in the database
- Does the order of sections in readme.txt matter?
- Correct check for any admin page with editor
- Add column in WP user but it goes wrong
- modify wordpress default search
- How to perform a heavy and long process in cron jobs?
- Woocommerce extend tax report with custom column
- Is file_get_contents() the only way for plugins reading local files OR does WP_Filesystem_Direct::get_contents() even work?
- Hook into Jetpacks Publicize without using a post type
- How to limit number of number of categories displayed by categories widget
- wordpress how to query wp_options table
- rest_no_route on custom API endpoint wordpress
- How to only load css for used blocks on frontend
- adding wp-cli commands to plugin: how to document to users?
- Additional classes `undefined` after saving post in Gutenberg
- How do you submit a Gutenberg plugin?
- Creating an empty page programatically
- Multiple API Endpoints (wp_remote_get)
- plugin_dir_url & plugin_basename not working when plugin dir is outside wordpress dir
- How to replace default comments with custom HTML?
- WP nonce field checkbox prints checked=’checked’ outside input field
- Shortcode not appearing when used as post content in wp_insert_post() or possibly, shortcode not being registered at all
- Make dynamic string translatable
- Creating two tables in database on activation hook
- Adding Custom CSS with PHP
- How to receive notification of deprecated API elements and functions?
- It is possible to pass $args that sent by add_settings_field() inside another function?
- Change reminder email date to 14 days before
- Woocommerce get_term_by() in transition_post_status hook doesn’t works
- Why is that only the first row getting inserted into Mysql table when i import csv file on backend custom plugin?
- Adding Amchart Interface to WordPress API
- WordPress Own Rewrite Rules
- Don’t print customizer styles when no setting has been used
- Buddy Press restrict the capability to edit users
- Plugin with functions inside a class & how to trigger WP CRON
- “Headers Already Sent” Nightmare on Plugin
- add_settings_error on validating plugin options API
- Problem to return more than single line captions
- Unable to show a message after plugin activation
- How to get an array out of a nav menu if it’s a plugin?
- Can I access WordPress API’s from within plugin scripts?
- Is there a way to make is_search() always return false
- Ajax url value to pass ‘variable’ to use in query
- Apply Filters Causing a 500 Internal Server Error
- Need someone to help you want to manage points for members to code interface functions? thank you
- WordPress plugin boilerplate AJAX functionality
- Run different permission_callback depending on HTTP method of custom REST API endpoint