Skip to content

Actions and Filters

Jo Dickson edited this page Jan 15, 2019 · 3 revisions

The UCF WordPress Theme executes the majority of its logic by hooking into existing action and filter hooks that fire as WordPress loads. These action and filter functions are documented here for reference, in case a developer chooses to de-register them and redefine their own custom logic in a child theme.

Everything under this section of the wiki refers to the functions defined in the UCF WordPress Theme that hook into existing hooks in the WordPress core--if you're looking for information on custom hooks provided by the theme, please see our action and filter hook docs.


What Actions and Filters are Defined in This Theme?

Use the wiki's sidebar navigation to view this theme's defined action and filter functions.


How Do I Remove an Action or Filter Defined in the UCF WordPress Theme?

If you wish to completely remove an action or filter added by the UCF WordPress Theme in a child theme, you'll need to use remove_filter(); however, there is a slight catch: because a child theme is always loaded before its parent theme, you won't be able to call remove_filter() directly to remove an action/filter set in the parent, because it won't be registered yet.

To work around the child/parent theme load order, you'll have to add all remove_filter() calls to WordPress's after_setup_theme hook, in your child theme's functions.php file:

// Your child theme's functions.php
function enable_unused_templates() {
    remove_filter( 'template_redirect', 'ucfwp_kill_unused_templates' );
}
add_action( 'after_setup_theme', 'enable_unused_templates' );

In this real-world example, we've un-registered the ucfwp_kill_unused_templates filter from the template_redirect hook, which re-enables front-end views that are otherwise turned off by the UCF WordPress Theme (such as author, attachment, search views, etc.). You could then define your own custom filter for template_redirect if you wish.

NOTE: These instructions are provided for reference only--use your best judgment when de-registering actions and filters in this theme. Know that removal of code could have unintended consequences and possibly break things.