Common Hooks

Categorized reference of frequently-used WordPress action and filter hooks.


Initialization Actions

Core Bootstrap

HookWhen it FiresTypical Use
muplugins_loadedAfter MU plugins loadMU plugin initialization
plugins_loadedAfter all plugins loadPlugin initialization, loading textdomains
setup_themeBefore theme loadsTheme prerequisites
after_setup_themeAfter theme loadsTheme setup, add_theme_support()
initAfter WP fully loads, before headersRegister CPTs, taxonomies, shortcodes
wp_loadedAfter WP and all plugins/themes loadLate initialization
wpAfter WP query is parsedQuery-dependent setup

Admin Initialization

HookWhen it FiresTypical Use
admin_initFirst thing on admin pagesAdmin-only setup, option registration
admin_menuWhen admin menu is createdAdd menu/submenu pages
admin_bar_menuWhen admin bar is createdAdd admin bar items
current_screenAfter current screen is setScreen-specific setup

REST API

HookWhen it FiresTypical Use
rest_api_initWhen REST API initializesRegister REST routes

Request Lifecycle Actions

Frontend

HookWhen it FiresTypical Use
template_redirectBefore template loadsRedirects, access control
wp_enqueue_scriptsFrontend script/style enqueue pointEnqueue CSS/JS
wp_headInside <head>Meta tags, inline CSS
wp_body_openAfter <body> opensSkip links, tracking scripts
wp_footerBefore </body>Deferred scripts, analytics
shutdownAfter response sentCleanup, logging

Admin

HookWhen it FiresTypical Use
admin_enqueue_scriptsAdmin script/style enqueue pointEnqueue admin CSS/JS
admin_headInside admin <head>Admin-specific styles
admin_footerAdmin footerAdmin scripts
admin_noticesTop of admin pagesDisplay notices

Content Actions

Posts

HookWhen it FiresTypical Use
save_postPost is savedCustom meta, validation
save_post_{post_type}Specific post type savedType-specific processing
wp_insert_postAfter post inserted/updatedPost processing
before_delete_postBefore post deletedCleanup related data
delete_postPost is deletedRemove related data
trashed_postPost moved to trashSoft-delete handling
transition_post_statusPost status changesStatus change notifications

Comments

HookWhen it FiresTypical Use
comment_postComment is savedComment processing
wp_insert_commentComment insertedComment notifications
delete_commentComment deletedCleanup
transition_comment_statusComment status changesModeration handling

Terms & Taxonomies

HookWhen it FiresTypical Use
create_termTerm is createdTerm processing
edit_termTerm is editedTerm updates
delete_termTerm is deletedCleanup
set_object_termsTerms assigned to objectRelationship handling

User Actions

Authentication

HookWhen it FiresTypical Use
wp_loginUser logs inLogin tracking, redirects
wp_logoutUser logs outCleanup
wp_login_failedLogin attempt failsSecurity logging
auth_cookie_validAuth cookie validatedSession management

User Management

HookWhen it FiresTypical Use
user_registerNew user createdWelcome emails, defaults
profile_updateUser profile updatedProfile processing
delete_userUser deletedCleanup user data
set_user_roleUser role changesRole-based setup

Media Actions

HookWhen it FiresTypical Use
add_attachmentAttachment uploadedPost-upload processing
edit_attachmentAttachment editedAttachment updates
delete_attachmentAttachment deletedCleanup
wp_handle_uploadFile uploadedCustom upload handling

Widget & Block Actions

HookWhen it FiresTypical Use
widgets_initWidget area registrationRegister sidebars/widgets
dynamic_sidebarSidebar rendersSidebar customization
initBlock registration pointRegister blocks (with register_block_type)

Cron Actions

HookWhen it FiresTypical Use
wp_scheduled_deleteDailyTrash cleanup
wp_update_pluginsTwice dailyPlugin update checks
wp_update_themesTwice dailyTheme update checks
Custom hooksAs scheduledBackground tasks

Content Filters

Titles & Content

HookWhat it FiltersReturn Type
the_titlePost titlestring
the_contentPost contentstring
the_excerptPost excerptstring
get_the_excerptRaw excerptstring
the_content_more_link"Read more" linkstring
wp_trim_excerptAuto-generated excerptstring

Post Data

HookWhat it FiltersReturn Type
the_permalinkPost permalinkstring
post_linkPost type permalinkstring
post_type_linkCPT permalinkstring
the_authorAuthor display namestring
get_the_datePost datestring
the_categoryCategory liststring
the_tagsTag liststring

Query Filters

Pre-Query

HookWhat it FiltersReturn Type
pre_get_postsWP_Query before executionvoid (modify $query)
query_varsRegistered query varsarray
requestRequest query varsarray

SQL Modification

HookWhat it FiltersReturn Type
posts_whereWHERE clausestring
posts_joinJOIN clausestring
posts_orderbyORDER BY clausestring
posts_distinctDISTINCT clausestring
posts_fieldsSELECT fieldsstring
posts_clausesAll clausesarray
posts_requestComplete SQL querystring

Post-Query

HookWhat it FiltersReturn Type
the_postsQuery resultsWP_Post[]
found_postsTotal found postsint

Template Filters

Classes

HookWhat it FiltersReturn Type
body_classBody CSS classesarray
post_classPost wrapper classesarray
nav_menu_css_classMenu item classesarray
comment_classComment classesarray

Template Selection

HookWhat it FiltersReturn Type
template_includeTemplate file pathstring
single_templateSingle post templatestring
archive_templateArchive templatestring
search_templateSearch templatestring
404_template404 templatestring

HookWhat it FiltersReturn Type
wp_nav_menuComplete menu HTMLstring
wp_nav_menu_itemsMenu items HTMLstring
wp_nav_menu_objectsMenu item objectsarray
nav_menu_link_attributesMenu link attributesarray
walker_nav_menu_start_elMenu item elementstring

Media Filters

HookWhat it FiltersReturn Type
upload_mimesAllowed MIME typesarray
wp_handle_upload_prefilterUpload before processingarray
wp_generate_attachment_metadataAttachment metadataarray
image_size_names_chooseImage size optionsarray
intermediate_image_sizesImage sizes to generatearray
wp_get_attachment_image_attributesImage tag attributesarray

Authentication Filters

HookWhat it FiltersReturn Type
authenticateAuthentication resultWP_User|WP_Error
login_redirectPost-login redirect URLstring
logout_redirectPost-logout redirect URLstring
login_urlLogin page URLstring
lostpassword_urlPassword reset URLstring

Permission Filters

HookWhat it FiltersReturn Type
user_has_capUser capabilitiesarray
map_meta_capMeta capability mappingarray
editable_rolesRoles user can assignarray
show_admin_barAdmin bar visibilitybool

REST API Filters

HookWhat it FiltersReturn Type
rest_pre_dispatchPre-dispatch (short-circuit)mixed
rest_request_before_callbacksBefore route callbacksWP_REST_Response|WP_Error
rest_request_after_callbacksAfter route callbacksWP_REST_Response|WP_Error
rest_prepare_{post_type}Post responseWP_REST_Response
rest_prepare_commentComment responseWP_REST_Response
rest_prepare_userUser responseWP_REST_Response

Email Filters

HookWhat it FiltersReturn Type
wp_mailEmail argumentsarray
wp_mail_fromFrom addressstring
wp_mail_from_nameFrom namestring
wp_mail_content_typeContent typestring

Option Filters

HookWhat it FiltersReturn Type
pre_option_{option}Before retrievingmixed (short-circuit)
option_{option}Retrieved valuemixed
pre_update_option_{option}Before updatingmixed
default_option_{option}Default valuemixed

Script & Style Filters

HookWhat it FiltersReturn Type
script_loader_tagScript tag HTMLstring
style_loader_tagStyle tag HTMLstring
script_loader_srcScript URLstring
style_loader_srcStyle URLstring

Cron Filters

HookWhat it FiltersReturn Type
cron_schedulesAvailable schedulesarray
pre_schedule_eventBefore schedulingnull|bool
pre_unschedule_eventBefore unschedulingnull|bool

Block Editor Filters

HookWhat it FiltersReturn Type
allowed_block_types_allAllowed blocksarray|bool
block_editor_settings_allEditor settingsarray
render_blockBlock output HTMLstring
render_block_{block_name}Specific block outputstring
block_categories_allBlock categoriesarray