0
0
Wordpressframework~10 mins

Hook priority and arguments 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 a WordPress action hook with default priority.

Wordpress
add_action('init', [1]);
Drag options to blanks, or click blank then click option'
A'my_function', 5
B'my_function', 10
C'my_function'
D'my_function', 15
Attempts:
3 left
💡 Hint
Common Mistakes
Adding priority when not needed
Using incorrect quotes around function name
2fill in blank
medium

Complete the code to add a function to a WordPress filter hook with priority 20.

Wordpress
add_filter('the_content', [1]);
Drag options to blanks, or click blank then click option'
A'modify_content', 10
B'modify_content', 5
C'modify_content'
D'modify_content', 20
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to add priority argument
Using wrong priority number
3fill in blank
hard

Fix the error in the code to correctly specify the number of accepted arguments for the hook.

Wordpress
add_action('save_post', 'save_extra_data', 10, [1]);
Drag options to blanks, or click blank then click option'
A2
B1
C0
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Setting accepted arguments to 0 disables arguments
Setting too many arguments causes errors
4fill in blank
hard

Fill all three blanks to add a filter with priority 15 and accept 2 arguments.

Wordpress
add_filter('widget_title', [1], [2], [3]);
Drag options to blanks, or click blank then click option'
A'custom_title'
B15
C2
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping priority and accepted arguments
Using default priority when a specific one is needed
5fill in blank
hard

Fill all three blanks to add an action with function 'log_event', priority 5, and accept 3 arguments.

Wordpress
add_action('wp_footer', [1], [2], [3]);
Drag options to blanks, or click blank then click option'
A'log_event'
B5
C3
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of arguments
Using default priority instead of specified