0
0
Wordpressframework~10 mins

Common action hooks in Wordpress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add a function to the WordPress 'init' action hook.

Wordpress
add_action('init', [1]);
Drag options to blanks, or click blank then click option'
A'admin_menu'
B'wp_head'
C'the_content'
D'my_init_function'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a hook name instead of a function name.
Not putting the function name in quotes.
2fill in blank
medium

Complete the code to hook a function to run when the WordPress admin menu is being built.

Wordpress
add_action('admin_menu', [1]);
Drag options to blanks, or click blank then click option'
A'my_admin_menu_function'
B'template_redirect_function'
C'init_function'
D'wp_footer_function'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function name unrelated to admin menu.
Confusing hook names with function names.
3fill in blank
hard

Fix the error in the code to correctly hook a function to the 'wp_footer' action.

Wordpress
add_action('wp_footer', [1]);
Drag options to blanks, or click blank then click option'
AmyFooterFunction()
Bmy_footer_function
C'my_footer_function'
D'myFooterFunction()'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the function name without quotes.
Including parentheses when passing the function name.
4fill in blank
hard

Fill both blanks to add a function with priority 15 and 2 accepted arguments to the 'save_post' action hook.

Wordpress
add_action('save_post', [1], [2], 2);
Drag options to blanks, or click blank then click option'
A'my_save_post_function'
B10
C15
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong priority number.
Not passing the function name as a string.
5fill in blank
hard

Fill all three blanks to add a function to the 'template_redirect' hook with priority 20 and accepting 1 argument.

Wordpress
add_action([1], [2], [3], 1);
Drag options to blanks, or click blank then click option'
A'template_redirect'
B'my_template_redirect_function'
C20
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up hook and function names.
Using wrong priority number.
Not passing strings for names.