The after_setup_theme
action hook is generally used for setting up theme features and functionality. It’s called after the theme is loaded and before the template is rendered. It’s a good place to set up things like theme support for certain features, register custom post types, or define custom image sizes, among other things.
On the other hand, the init
action hook is called after WordPress has finished loading but before the template is rendered. It’s a very early hook that’s often used for initializing functionality like registering custom post types, taxonomies, or shortcodes, among other things.
So the main difference between the two hooks is their timing. after_setup_theme
is called slightly later than init
, after the theme has been fully loaded, so it’s a good place to set up theme-specific features. init
, on the other hand, is called very early in the WordPress loading process, so it’s a good place to set up general functionality that’s not specific to the theme.
That being said, both hooks can be used to register menus with register_nav_menus()
. However, the recommended hook is after_setup_theme
because it’s a better fit for setting up theme-related features.
Leave a Reply