Command init and after_theme_support Wordpress

Asked

Viewed 21 times

2

Could anyone help me understand the functionality of these commands in Wordpress:

init 

and

after_theme_support

1 answer

1

I believe you meant add_theme_support or after_setup_theme instead of after_theme_support. Well, there it goes:

The add_theme_support is a function called usually in the functions.php to add theme components.

add_theme_support('COMPONENTE_DO_TEMA', array('PARÂMETROS_DO_COMPONENTE','...','...'));

The after_setup_theme is a parameter used in the function add_action for a function to run as soon as the theme has been loaded, right after the execution of functions.php. Usually used to perform settings and change theme options.

add_action('after_setup_theme','SUA_FUNÇÃO_AQUI');

The init is a parameter also used in the function add_action, but different from after_setup_theme, it performs a function as soon as Wordpress boots, but before the headers be sent. Generally used for plugin startup.

add_action('init','SUA_FUNÇÃO_AQUI');

The big difference between the after_setup_theme and the init is that in the execution of init the user will already be properly authenticated.

You can search for more details on wordpress documentation and examples of the use of init and of after_setup_theme in the code reference guide of Wordpress.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.