Out of the box WP relies on Template Hierarchy to resolve and load template. The default assumption is that (most) template are in the root of the theme and follow the naming conventions.
Placing template files elsewhere essentially requires rebuilding Template Hierarchy in your code with different assumptions. This used to be crazy inconvenient, but WP 4.7 introduced {$type}_template_hierarchy
hook, which makes it significantly easier.
As a personal aside I think native WP template simply doesn’t scale meaningfully to complex use cases. If there are enough templates to clutter the directory, then I would move to a different template engine (such as Twig) altogether. Of course that is hardly mainstream technique in WP development.
I have an example of template hierarchy override in my Meadow project for Twig integration, but same works for just changing up logic for PHP templates.
Related Posts:
- Theme, WordPress Version, MySQL Version, PHP Version Update affected files and folders
- Removing the references to the wp-content folder
- Can wordpress theme folder name be changed freely and nothing technically happens
- How to change the language for the front-end only?
- How do I add support to my theme for custom menus?
- How do I white label my self-hosted site created by wordpress?
- Switching themes without losing widgets?
- How to use media upload on theme option page?
- Multiple image logo for theme
- How do i structure my theme folder to avoid one huge list of files
- Loading template files from a subfolder in my theme?
- Hide Twenty Eleven Theme From Themes Page
- How to use scss in wordpress theme?
- How to get Ajax into a theme – without writing a plugin?
- Is it mandatory to have a link to the theme designer?
- How do I change Twenty Nineteen’s primary color without using the color slider in the theme customizer?
- WordPress as Backend, Laravel Front End: How to connect Routes?
- Updating custom theme that is built from scratch
- single.php change into a modal popup bootstrap wordpress
- Exclude stylesheet from admin
- How to tell a theme to use different .mo and .po files?
- Can I apply a WP theme to a specific custom page template?
- Making an IE only site (Like a Mobile only site)
- WordPress can’t see symlinked theme in Ubuntu
- How do I move the page title (H1) to header.php (outside of the loop) in a WordPress theme?
- Find proper “text domain” within theme
- Does theme update also update a child theme zip
- Investigating complex themes still slow even with WP caching
- What are the things that will be affected in case there is some wordpress updates or theme updates?
- Create more than one section in Theme Customizer
- setting a different theme for specific category in wordpress
- Color palet in the WordPress’ front-end?
- How do you approach block structured content?
- Child Theme not overriding a template section on live site – but is on local site
- Online theme customizer missing details
- need to aply a different style sheet for a specific page template
- WordPress themes incomplete installation or installation problem
- Problem of running development copy of WordPress on WebMatrix?
- Switching content between summer and winter
- How does WordPress load themes? It doesn’t see mine (symlinked)
- Buddypress User Settings template location? [closed]
- How to code static pages in WordPress
- How can I manually activate my previous theme without browser access to dashboard?
- Can “Classic Editor” plugin help to replicate the old website / theme development experience from c. 2011?
- Creating custom meta box throws PHP warning error in WordPress
- What is the point of needing add_theme_support( ‘html5’) in WordPress 5.x
- Plugin and themes are adding the same stylesheets
- How to display footer menus in wordpress
- Color Options from Theme Customizer API not returning via get_theme_mod()
- How do I manually revert back to my old theme?
- Modifying the markup in the Tag Cloud widget?
- Debugging in WordPress at Theme installation [duplicate]
- understanding theme hierarchy
- wp_enqueue_style $dep argument does nothing?
- Posts as filtered list – expandable
- Is it a good practice to disable wpautop for premium themes?
- How to remove current theme customizations
- How to use custom page templates in a theme that hides page template option?
- Create QuickStart Package for WordPress just like in Joomla
- How to include stylesheet in custom admin using parent_slug
- After installing a free theme, my wordpress turns into text mode when accessing remotely
- Jquery Theme Roller to WordPress
- Implementation of language_attributes function
- why is this script not working on my site
- is theme network enabled?
- Pharmacare theme login page / login modal redirection to custom URL
- theme installation not working
- wordpress-theme 2017: featured image behaviour: where to set the height of the featured image?
- Changing a parent theme safely
- Trying to create a child theme with plugin
- How exactly does WordPress load themes from api.wordpress.org?
- Own Theme custom CSS does not display in editor but works in page
- Remove Read More Buttons
- Theme-based character encoding issue
- Linkedin not returning right info
- how to load rtl.css file before style.css [duplicate]
- CSS/JS is not working in multi lang installation
- Error while downloading WordPress themes
- Theme stops media uploader from working
- div having different appearances in different themes
- Create a live demo gallery for themes
- Satoshi WordPress Theme – Portfolio SetUp Issues
- How to make a website like the ones in theme demos? [closed]
- How to create an Single-Portfolio page?
- Page structure using The Customizer Api
- theme 2016 – customize css – nothing happens
- Can’t upload the theme
- Divi theme including javascript
- “Parse error: syntax error, unexpected” and the WordPress Theme Editor no longer working!
- Installing themes from an external website [closed]
- Best Practice Jumbotron Image for WordPress ~ Responsive
- How to make a page extend full screen [closed]
- Should you directly edit Template Parts and Templates from themes?
- Remove ALL HTML from single page
- Remove Google Fonts from parent theme within a child theme [closed]
- Is it possible to dynamically show different themes for different users? [duplicate]
- Why does WP theme not look like promoted? [closed]
- Remove image next to header image on WellExpo theme [closed]
- How do I get rid of the Mindblown and the book recommendations?
- Adding PHP code to single template in 2023 edition of WordPress theme