You might want to look at the routine that WP uses for this: locate_template()
. It is in wp-includes/theme.php
and is called from a number of functions in that file. Those functions are used by wp-includes/template-loader.php
to select the correct type of template based on the current page and then walk up the theme hierarchy looking for a match.
Related Posts:
- Get image URL from media library in input
- How to provide page_template path in custom plugin using WordPress
- Include theme header and footer in custom plugin
- Pass PHP variable to javascript
- Custom media upload content for inserting custom post shortcode
- Redesigning Custom Post Type “Add New” page
- How to Remove Certain Screen Options and Meta Boxes from add/edit post type?
- Is it possible to define a template for a custom post type within a plugin independent of the active theme?
- How to add custom content template part for a custom post type on main query using a plugin
- Page Templates from plugin not working after upgrading WP to 4.7 or upper version
- How can I add a custom header to a custom template in a plugin without using the theme folders
- How to load a new template page according to a particular URL?
- How to get the custom page get_permalink?
- Updating post meta for custom post types
- Template for custom post type shows all posts instead of just one
- Custom url structure for custom template
- remove custom taxonomy metabox form custom post type
- Custom Post Type Statuses
- How to Build a Movie Library in WordPress 3.x
- Way to hook into a sidebar call to replace it with a custom sidebar
- Override comments.php template with plugin
- Can we use a webservice with WordPress?
- Loco Translate: Custom Post and Custom Taxonomy Labels not translated in wp-admin menu
- WP Post Template – Templates in own folder
- Register Page Template from Plugin
- Is it possible to create Custom Post plug-in?
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- Making a Template for a CPT created by a plugin
- Plugin-generated pages use Not Found or Pages Archive templates?
- Perform internal redirect in WordPress?
- Unable to delete custom post types, confusion around capabilities
- Adding CSS to custom post type admin page causes error
- Redirect to another page using contact form 7? [closed]
- how to force tag page layout to use same as search layout?
- How can I use a file in my plugin as a replacement for single.php on custom-post-type query?
- Disable Individual Plugins (specifically in Custom Post Types) on a per-post basis?
- Using ACF default value to autoincrement a number field
- Default taxonomy template in plugin, override in theme
- How to Resize the Custom Post Images?
- Amazon.com intergration with WordPress?
- Adding custom meta boxes to specified custom post type
- How to use template inside plugin shortcode with variables for big HTML code
- Plugin generated unexpected output – No PHP errors
- How do I show content from a plugin using the template the site is currently working with?
- Custom Post Type template for homepage
- Custom Post Type, Custom Columns List
- Pass PHP variable to javascript
- Need to edit author permissions | custom taxonomy
- Is it possible to pin a post in second position from top
- How to get the custom field value using SQL query
- Check if theme supports sidebar
- How to display the category name in the tab and post inside the tab in WordPress?
- custom post type plugin error [closed]
- How to display the custom post related blog by category?
- Problem with checked box on wp car manager plugin
- Ultimate Members Default Post Layout problem
- custom post type get_posts() function not work
- Create multiple posts when a custom post is created
- $wpdb->insert not working inside save_post tag
- Cannot view Custom Post Type no matter what I try
- How to prevent redoing get_posts queries and make results available to other scripts?
- how to do Thematic like this website using wordpress?
- How to add jquery to my custom post type wp plugin
- show Visual form builder in the front end
- Synch Custom Post Types (and Custom Fields, Cats, etc.) Between WordPress Sites
- get_option include in my adsense
- Making a Custom Post Type Publish Loop
- Is an Office a custom post type [closed]
- WordPress show different custom post type
- Wrong block appender button showing
- How to make a Template page to show the information of different things Shop and Product page?
- How to access the page without registering in wordpress
- CPT template is not being automatically used single post pages
- How to make content as required in custom post type?
- public custom posts not showing in my wordpress plugin
- How to fetch WordPress Gallery Images to a Custom Post Type?
- Remove H1 title in admin post edit screen
- How to Display News in a Timeline with Headline, Category, and Time?
- Load a custom post type template.html from a plugin
- TinyMCE Styles Dropdown not adding html tags other than span
- WordPress Widget – Saving multidimensional arrays into $instance
- “Custom Post Type Permalinks” plugin URL strcuture
- How to change the name of the “edit my profile” link in the WordPress admin backend
- Ordering taxonomies by rank
- Getting wp.me shortlink for wordpress custom post type
- Count posts by type including drafts and pending posts
- WordPress get_avatar function not correct working
- How can i change the texts of plugin (created by me) in wordpress admin?
- Can a Plugin Override New User Default Role Type
- Customised plugin failed to install and activate
- Display custom content using page.php from theme
- Which file of wordpress manage plugins functionalities?
- Inject HTML meta tag inside wordpress tag using add_shortcode
- How to test ‘upgrader_process_complete’ hook in plugin development?
- Plugin Development Form Self Submission
- How to create a child/addon plugin
- How to secure the release of WordPress plugins / avoid copying plugins?
- Plugin Not Working After Being Uploaded To WordPress Plugin Repository
- How can I remove the WordPress-Version (?ver=5.x) from my plugin
- Difference and examples of esc_attr__() and esc_attr_e()