This Hook is called when each page is loaded after theme is initialised. This is used for the basic theme setup, registration of the theme features and init hooks. The basic use of this hook can be seen on the default themes that comes with WordPress Installation. Following is the example code from twentyfifteen default theme.
This page was moved to https://developer.wordpress. org /reference/hooks/after_ setup _theme/ except above language locator. Retrieved from https:// codex .wordpress. org /index.php?title=Plugin_ API/Action_Reference/after_setup _theme&oldid=169775 , 4/1/2021 · Defined at: wp-settings.php, line 538. Codex: Plugin_API/Action_Reference/after_setup_theme. Fires after the theme is loaded. Related Functions: make_site_theme, wp_get_theme, get_theme, resume_theme, delete_theme, wp_get_themes. Related Hooks: setup_theme, after_signup_site, after_theme_row,.
If you look at WordPress Codex :: Actions Run During a Typical Request, you will notice that the action hook after_setup_theme is fired significantly earlier on than that of the action hook wp . What does this mean?, Must be called in the themes functions.php file to work. If attached to a hook, it must be after_setup_theme. The init hook may be too late for some features. Example usage: add_theme_support ( ‘title-tag’ ) add_theme_support ( ‘custom-logo’ , array ( ‘height’ => 480, ‘width’ => 720, ) ) Top ?.
after_setup_theme action hook is fired before the actual $wp->init() which Set up the current user and only then init action hook is fired which means that they are pretty much the same with one major difference and that is at after_setup_theme the user is not authenticated, and at init he is (assuming that we are talking about an actual user).
7/18/2012 · Ill show this function in its entirety when we take a look at the final function, but I find it useful to attach this function to the after_ setup _theme action to ensure that the post is created when WordPress sets up the theme. Programmatically Create a Post in WordPress. This is the TLDR version of all of the code covered in this article.