There’s filters for that.
Example:
add_filter( 'template_filter', 'wpse_102706_filter_callback', 10, 2 );
function wpse_102706_filter_callback( $defaults, $case )
{
$args = wp_parse_args( array(
'some_key' => 'some_modified_value'
), $defaults );
return $args
}
Then in your template just add in the defaults:
apply_filters( 'template_filter', array( 'some_key' => 'default_val' ), 'single' );
More info in Codex about the Plugins API.
Related Posts:
- Single Page theme [closed]
- What is the point of using the front-page.php template? [closed]
- Using classes instead of global functions in functions.php
- How to insert a logo in the header?
- How to move page template files like page-{slug}.php to a sub-directory?
- How to move page templates to custom folder?
- Page template in two level deep folder
- Create “File-less” Page Template in Functions.php
- Is it possible to manipulate the list of page templates?
- How can I get wp_head() as a string instead of echoing it?
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Removing the default sidebar from admin panel
- Is there an error in get_the_tag_list()?
- Do I really need the div class entry?
- Toggle Sidebar Display
- Where can I access my custom page template?
- Disable front-page.php template
- How to enable template page only for a post id page
- create-guten-block in wordpress theme?
- Override template file i subfolders
- How to add “Template” option in page attributes panel?
- Move default page templates to sub directory
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- How to use get_template part in the plugin?
- How do I get the trackback count of a post in wordpress without writing an SQL query?
- Load sidebar template just once to prevent multiple animations
- Replace single_template filter with what for default posts?
- Need help with adding templates (archives and sitemap) to WordPress child theme
- Template for landing pages
- How to add menù section to my WordPress template?
- Why still output /wp-content/themes/twentynineteen?
- Templates dropdown not appearing using _s theme (underscores)
- Create theme for mobile phones and tablets only?
- Can’t change theme name
- Template for front page (latest posts)
- How to show children pages as array
- Create a variable with string, array or multiple values
- Can you create a custom page with content in the center already defined?
- Query custom post type and showing its content
- Is there a way to have WordPress autodetect page templates in the page-templates directory and any sub-folders?
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?
- How to automatically set a Template Page Name next to a page in menu screen such as WooCommerce pages, front page, or posts page in wordpress?
- How To Add New Option Types To Option Tree?
- Where do I find the functions triggered within a hook?
- One button to change all settings in theme customizer?
- Registering Sidebars and Sidebar Widgets. Sidebar Widgets Not Displaying
- How do I get a parent theme modification from a child theme?
- Pagination & get_pages?
- how to pull wordpress post comments to a external page
- Change date number to another language/script?
- Is using eval() ok in this scenario
- Should I update my _s theme?
- Dequeue script in template isn’t working
- Setting a Default ‘Theme Location’ When Creating a Menu
- Custom php page in WordPress theme?
- Adjust which tempalte a page uses with a function?
- Can’t access WordPress functions in file called via Ajax?
- How to correctly add JQuery in a WP theme?
- Check if password protected post is visible
- how to change a theme slug
- Same theme name issue with wordpress repository theme
- Removing feeds from header using a function?
- How to add code in the content area in a WordPress theme?
- Can I show all the template files that are being used on my site?
- Change the template of multiple multisite pages at the same time
- How to add theme support?
- Multiple Page Templates & CSS
- after renaming my wp-content folder, how do I upgrade my wordpress version?
- WordPress theme switcher
- Limitations when modifying wp_title with a filter
- Pass variable to hook. Its possible?
- WP_bootstrap_Navwalker_issue [closed]
- Font Awesome 5 Free – far working but fas is not? [closed]
- correct tags for validating input types
- Renaming a theme so it aids SEO and the theme used is hidden
- Is there any tool to find lines of codes responsible to generate front-end HTML elements?
- Will my site get messed up when the wordpress theme updates if I edited the html code in the editor to change footer?
- How to correctly enqueue the parent and child theme stylesheets in the creation of a child theme? [duplicate]
- How to identify and hide/remove an element from a WordPress page [closed]
- searchform.php doesn’t work properly
- Password protect a custom template
- Shortcodes do not work in own template
- Adding Bootstrap to WordPress TwentySixteen Theme
- New to WordPress – Read the Codex, Other Docs; Still Confused
- Confused by the behaviour of “front page” / “home” templates
- Get video from the post on homepage
- WordPress Themes Directory: Template which hits the standards?
- How to change a local wordpress installation xml export file urls? and change them to what if you don’t have a live website?
- How to make menus, footer, sidebars multi language
- Different templates for each category level
- Child theme in separate WordPress Install
- Using Customizer value in an external PHP file inside a theme
- Import from HubSpot COS into WordPress 4?
- Theme automatically inserting “more” tag on every post
- How get the 10 most viewed pages (not post)
- Using wp_enqueue_script with social media buttons?
- Add custom css to theme
- Image Size wrong during upload
- How to create full header but keep content narrow
- Correct way to make a custom block theme responsive