PHP: Why use add_action?
-
Hello π
I’ve been using wordpress for 6-7 years, and I’m starting to get into the “php side” of it.I’m currently building a simple theme just to learn some basics.
My question is the following:
Why should I use “add_action” instead of simply declaring the things I want to do?
For example, why write:function arphabet_widgets_init() { register_sidebar( array( 'name' => 'Home right sidebar', 'id' => 'home_right_1', 'before_widget' => '<div>', 'after_widget' => '</div>', 'before_title' => '<h2 class="rounded">', 'after_title' => '</h2>', ) ); } add_action( 'widgets_init', 'arphabet_widgets_init' );
instead of just write:
register_sidebar( array( 'name' => 'Home right sidebar', 'id' => 'home_right_1', 'before_widget' => '<div>', 'after_widget' => '</div>', 'before_title' => '<h2 class="rounded">', 'after_title' => '</h2>', ) );
I think I’m missing something very important here π
Thanks!
Best
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘PHP: Why use add_action?’ is closed to new replies.