If you’re just trying to add a template within the theme, name your file single-profile.php
and that will apply to all single “profile” CPTs.
But you mentioned you don’t want to touch the child theme. You could instead create a plugin and use a page_template
filter to use your plugin’s single-profile.php
template instead of any of the theme templates.
You would create a plugin folder, put your single-profile.php
file in that folder, and add a plugin.php
file that contains something like
<?php
add_action('page_template', 'wpse_apply_profile_template');
function wpse_apply_profile_template() {
// If this is the CPT we're looking for
if(is_singular('profile')) {
// Apply this plugin's "single-profile.php" template
$page_template = dirname( __FILE__ . 'single-profile.php';
}
// Always return, even if we didn't change the template
return $page_template;
}
?>
Related Posts:
- Adding custom PHP to existing loop in Genesis
- Display current category title on category page
- Childs PHP files not overwriting Parent’s PHP files
- why is translation not working on theme?
- Genesis – Customize search form
- Is it possible to disable a function of a parent theme?
- How to override an unpluggable parent theme function?
- Adding a search form inside a div
- is there a simple way to list every templates / php files used to generate a specific page?
- Copyright info change in Theme Child PHP
- Add footer.php to WordPress child theme
- Setting up the child theme so as to enable right-to-left WordPress?
- How to override a non pluggable and non hookable function in a WordPress parent theme?
- Understanding WordPress child theme custom JS loading
- StudioPress: add meta tag to every page [closed]
- How to add specific menu on a specific page or pages
- Understanding child theme functions.php
- How to stop PHP code running when in a child theme
- Overriding a theme redux file in child theme
- Want to create Child theme, but already edited Parent theme css files and some php files
- integrating external php library into wordpress- the right way
- child theme inherticance and php autoload
- How do I target the child theme with get_bloginfo();?
- Adding tawk.to code just before body tag on functions.php file
- Can’t extend some core classes
- WordPress child theme fails to override parent navigation menu in /inc/structure/header.php
- Where to edit the template that is generating the code for dynamic_sidebar left-sidebar in the Understrap theme? [closed]
- Parent theme CSS overriding child CSS rules
- How to style options page in dashboard?
- wp_enqueue_scripts leads to error
- Replace part of a parent-theme customizer in the child-theme
- Adding function to Genesis genesis_header [closed]
- two columns of posts on homepage, one of them “favorites”
- How to edit php files in Child Theme?
- WordPress Child Themes
- Custom Background by Page IDs
- Copyright info change – Corporate Plus Theme PHP [closed]
- Started getting warning message following host’s PHP upgrade
- Why does the Woocommerce grouped template prints the unpublished products?
- How to edit HTML of my website on WordPress? [closed]
- Divi change project category slug
- How to specify the path for require_once in a child theme?
- Warning: printf(): Too few arguments in helpers.php file
- What’s a good way to allow overwriting files within a child theme if I want the same folder structure?
- WordPress filter load_textdomain_mofile not working inside a child theme’s functions.php but works form inside a plugin
- How do I check or test a WordPress Auto Year Change Script?
- How to have different site identity logos on each page on Astra Theme [closed]
- Include style.css in the Child Theme with PHP
- Problems clearing cache
- Removing “Powered by” footer using child theme PHP [closed]
- Overide Variable in Child Theme
- child parent styles enqueue order
- Creating a child theme after numerous edits to parent theme
- using wp enqueue style to create a CSS file specifically for a page template
- How to style injected code in header section?
- Genesis / custom template page / setting the page title and meta desc
- Randomize Color Scheme Selection in Theme
- Where should I copy a PHP file from wp-includes to, in order to override it in my child theme?
- Child Theme’s Read More Text
- Need advice on theme customizer and child themes
- Conditionally remove comments and post meta in functions.php
- Trying to change featured image from 180×180 to full width on home page
- Hard-coding a shortcode as the last menu item in primary navigation?
- How to edit background color of only one sidebar?
- Inline CSS header style priority function.php Child (no enqueing I think)
- Why would the child theme load in the Customize preview, but not on the site itself?
- Proper way to remove html code on child theme
- Child-Theme Category View with modified permalinks (%category% removed)
- remove_action from parent theme using child theme functions.php
- File from parent theme imported to child theme doesn’t work – any ideas?
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- Child theme overirde template-tags in a theme built on underscores in inc/template-tags
- PHP “warning include_once(): Failed to open stream” Simple HTML DOM in WordPress Child Theme
- AJAX numerical pagination problem in TwentyFifteen-child theme
- How to change the structure/order of sections in a WordPress theme? [closed]
- How to edit button permalink inside function.php using a child theme?
- How to locate parent theme functions and add functions to my wordpress child theme?
- How to let mobile navigation menu close when link is clicked?
- how to add functions to my function.php using a child theme?
- Modifying child theme’s header
- How to Change Site Elements based on referring URL
- Replace header with large image on home page only, using Genesis child theme
- WordPress files break if I edit them, but adding a closing PHP tag fixes it
- Add the shortcodes from the enfold theme to the other theme
- If i use a child theme to add new code blocks to header.php, how does it get inserted in the right place in parent’s header.php?
- How to override html codes in wordpress?
- random woocommerce categories are not showing when count enabled?
- Add Text Area To Child Theme’s Home Page
- Where to find the html for WordPress site? [closed]
- Child theme functions.php file change database entries
- How to remove image on single product and get product to span page?
- Removing get_template_part in child theme
- Modify arguments for parent theme’s `wp_register_style` via child theme
- Child theme not working properly
- If I define a variable in header.php, how do I make it available to templates?
- WordPress developer
- Inserting a shortcode into a genesis menu?
- Child-theme suddenly stopped working [closed]
- Divi – add title to mobile menu button
- How can I use AJAX in child theme template?