You’re looking for template_redirect
:
add_action('template_redirect', 'my_category_template');
function my_category_template(){
if(is_category(5)){ // <- category ID/title/slug
require "path/to/your/template.php";
}
}
If you only need to change the query arguments, then see Mike’s answer to this question
Related Posts:
- Gravity Forms field entries into wp_query loop [closed]
- Issues with title-tag and document_title_parts
- Define custom Page Template without its own .php file
- How to influence the information displayed on widget inside wp-admin
- When tax_query used, results disappear (0 =1 produced)
- Is there a hook or function I can use to display all theme files being used on a current page?
- Issue with get_theme_mod returning a blank value instead of the saved value
- WP_Query in functions.php
- Add action hook conditionally – only when home.php in use
- Show modified time if post is actually modified
- why doesnt is_home() work in functions.php
- Implementing DNS Prefetching with WordPress
- How can I tell if I’m on a login page? [duplicate]
- In WooCommerce I need to modify the thankyou.php page [closed]
- How can I add an extra WooCommerce hook
- Why get_header() or get_footer() does not run twice if called in the same php file?
- Set default options for inserting media
- Change parent theme file function in child themes functions.php
- Adding extra SVGs to TwentyNineteen child theme using class TwentyNineteen_SVG_Icons
- How to hook into the quick edit action?
- gform_after_submission content appears immediately after , not in post body [closed]
- How do I change parameters without changing the core
- WooCommerce add_action hook results in 500 error
- Increment price for Woocommerce Minicart [closed]
- how to change link of some wordpress pages
- Proper way of using functions in action hook?
- How to preserve edits to Name or Slug of term when using wp_update_term on save?
- Accepted arguments value in hook functions
- Get current page_id before loop, in functions.php
- How to properly add function called by action-hooked function to functions.php?
- Inserting a functions output after the content
- How to display post content instead of excerpt
- Add function to every post?
- How to delete taxonomy term when a wordpress user is removed?
- Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘greenday_head’ not found or invalid function name
- Don’t delete a page if it holds users
- Passing values from a widget to a function within a plugin
- Having a Function Inside of the Loop
- Which action does wp_update_user triggers?
- Wp_query function to search from product_title ‘OR’ product tags name
- How can I get my Script to work on the Login page?
- Trigger a custom function when option are saved in admin area
- Execute a ultimate member action when user role is updated
- How to filter, restrict and return posts based on custom user meta information
- Add other social networks to TwentyNineteen_SVG_Icons class in child theme?
- Replace a menu with widget or a custom template file programmatically
- Footer disappears when using the_content ( )
- Get User Login Data (date, time… )
- Display tags that only appear in one category
- jQuery does not work
- Why does re-using this function not work? [closed]
- Override the WordPress core function wp_referer_field
- How to return hook data when multiple parameters are present?
- Hook into a function without a hook?
- What is the text that appears beside the page titles in the list of pages in the WP admin?
- How to edit the Tags within the image file URLs?
- Control the srcset much more (not all sizes in it each time)
- How to add_filter html template to middle of content
- Filter yoast canonical add_action priority [closed]
- Auto log in hook is requiring a page refresh
- Wp-query Order By problem
- Possible to hook into Media Library preview File column and use a custom image?
- How is $current_page passed in woocommerce_account_orders function?
- Add back in child theme what the parent theme removed with remove_action
- Writing a function to detect an event
- WordPress wraps span tags into p tags
- Changing where my author box is printed
- Is it possible to use add_filter in an included file in the child theme’s functions.php?
- Add Adsense code between job listings – wp job manager plugin
- Replace admin header logo with an image
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- is_home() not working in functions.php file
- How to place a div inside a function that creates a div
- How to apply the ‘current_page_item’ class to an archive page in `wp_list_pages()`?
- Create a CUstom Archive by Year, but just for a Single Category
- Updating custom query var with multiple values
- query_vars treat as single var from URL
- Does hook have an effect on increasing the page load?
- What is the earliest Hook a Script can use?
- Populate acf-field, depending on block name
- How Do I Unhook This Parent Theme Function?
- SEARCH QUERY PLEASE HELP | call_user_func_array() expects parameter 1 to be a valid callback php
- Calling hooks in functions
- How to add custom column into custom post, when field is select
- True email confirmation for registration (keeping unvalidated users from user table)
- How to echo the translated custom field?
- Init hook for header send
- Optimizing multiple WP_querys into one call?
- Query is not work
- Why wp_ajax hooks doesn’t work?
- How to Delete Posts by title?
- How can I append and prepend something to all post hyperlinks without using ::before or ::after? PHP hook solution?
- Integrating custom API for post content into Admin interface & Public Website [closed]
- Why functions metaboxes is causing White Screen in Admin [closed]
- How do I add functionality to images?
- image_size with respect to aspect ratios
- Get category of post inside save_post hook
- Create section wit form
- Log in and out using custom pages, no logout confirmation and redirects for logging in and out 2023
- Copy and Modified WooCommerce function is_coupon_valid [closed]