You can filter the template with the template_include
filter. This example will filter the archive template for all archive pages. If you need to do this for a specific archive, use is_post_type_archive( $post_types )
as your condition. Put this in your functions.php
file of your child theme.
function my_archive_filter( $template) {
if ( is_archive() ) {
return 'path/to/includes/archive-desc.php'; // Path to your child theme template.
}
else {
return $template;
}
}
apply_filters( 'template_include', 'my_archive_filter' );
Edit: It should now fall back to the default template if the custom template fails for some reason.
Related Posts:
- how could I load a different template part by page
- Using same variable names in files added with get_template_part()
- If I define a variable in header.php, how do I make it available to templates?
- To close or not to close php
- How does printf( __( ) ); work?
- Return HTML Template Page with PHP Function
- Why do templates contain so many PHP tag pairs?
- Is there a way to parse shortcodes in PHP?
- Displaying a WooCommerce product via PHP
- What exactly does “Posts page” do in WordPress?
- Check if a menu is empty?
- Static Frontpage Pagination – Custom loop
- WordPress Template Engine?
- How to have a custom display for both woocommerce archive and product-category pages? [closed]
- wp_remote_get returns an error for valid URL
- On this day PHP code
- How to loop over custom fields in a page template?
- Blank on static home page?
- WordPress theme & site not loading after moving files
- Adjust the results quantity for Search Results page pagination
- Exclude pages with certain template from wp_list_pages
- get_template_part not working with ajax
- Use Timber/Twig to pull an image by image ID [closed]
- Categories Template Assistance
- Is it possible to use the featured image of a page as a css background without inlining?
- Unable to set right time in admin and frontend template
- Easiest way to show total number of subpages
- Switching between custom templates in a post type of the admin menu
- Use template for posts with a particular category grandparent
- Blank space at beginning of tag?
- Placing the_content inside shortcode not working
- Link to file in plugin directory from wordpress template?
- Password protecting content in custom template
- How to override wp-admin styling
- Add a Second Menu to a theme that only support 1 menu
- Custom excerpt function re-factoring
- Template part inside shortcode, unexpected reult
- Inject PHP code into “sidebar-content” – code before my WooCommerce sidebar widget?
- How to display user nickname (not display name) in PHP template?
- Custom Template 404 for specific custom post type
- An unwanted inline style is added to my body tag
- How to properly insert a link to a template in WordPress?
- Custom field value not saving when it contains a URL?
- Automatically add custom CSS to new posts using a category template
- Render ninja form inside markup
- How can I load a PHP page without using a Template?
- creating a second image attachment template?
- Mass update excerpt
- How can I get a single php file that is the equivalent of an existing WordPress page?
- Get and insert order email address to the PHP template inside HTML text
- Custom search results page not working with empty search
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- How to show single category archive
- code is skipping a div
- Issues getting PHP to display in category pages
- Change title only in dynamic page
- get_template_part based upon post’s category
- Secondary navigation menu on one page
- Enable custom logo upload if logo is not in header
- How can I edit the content in index.php? [duplicate]
- Woocommerce Show Single Product on Homepage
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- how to show only specific category for a template
- Show a different code on front page to other pages
- Does wordpress templates always in files or in database?
- get_template_part for specific page
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- PHP include is only working in certain places in my custom WP theme
- Use WordPress function in php file
- Adding wrapper elements in the_date() like in the_title()?
- How to get all author posts outside of author templates
- Add filter multiple times using only one master function
- Create a Blog Template Page
- Showing latest post without 301 redirect
- WordPress template page name displayed on screen
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- single.php with different look by category
- How to call multiple functions from multiple files into a WordPress page template [closed]
- Echo a shortcode div after every 3 posts
- How do I define a lookup table that will work across all PHP elements of the template?
- persist a variable set in header.php all the way down to footer.php
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- Removing WordPress Footer -without access to PHP code?
- How to set a template with wp_insert_post
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- Using ob_start and ob_get_clean with wordpress shortcode
- Why does the Woocommerce grouped template prints the unpublished products?
- Adding conditional text to a PHP Shortcode Template
- Create page template via functions.php?
- How to pass a variable to get_template_part that’s updated every time the template part is called?
- What’s a good way to allow overwriting files within a child theme if I want the same folder structure?
- how to display this functions?
- is_page_template showing partial results
- Adding regular php file to site
- Advice on creating a WP Archive Template with Custom Taxonomy (get_term_meta)
- add_filter function concatenate string and locate_template function
- How to render a block from php template
- Template Loop – add switch case php
- Override Admin menu icon
- Post repeated when opening in overlay, how do I solve this? [closed]