📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials WordPress Development Essential Hooks Reference

Essential Hooks Reference

4 min read Quiz at the end
Know these hooks: init, wp_enqueue_scripts, save_post, pre_get_posts, the_content filter.

Essential WordPress Hooks

HookTypeWhen
initActionAfter WP loads, before headers
wp_enqueue_scriptsActionQueue scripts/styles
the_contentFilterModify post content
save_postActionAfter post saved
pre_get_postsActionModify main query
wp_headActionInside head tag
wp_footerActionBefore end of body
admin_menuActionAdd admin menu items
// pre_get_posts -- modify main query without new WP_Query
function modify_home_query($query) {
    if (!is_admin() && $query->is_main_query() && is_home()) {
        $query->set('posts_per_page', 12);
        $query->set('post_type', ['post','news']);
    }
}
add_action('pre_get_posts', 'modify_home_query');