0
0
Wordpressframework~10 mins

add_action and add_filter 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 run when WordPress initializes.

Wordpress
add_action('[1]', 'my_init_function');
Drag options to blanks, or click blank then click option'
Ainit
Bwp_head
Cthe_content
Dadmin_menu
Attempts:
3 left
💡 Hint
Common Mistakes
Using a hook that runs too late like 'the_content'.
Confusing action hooks with filter hooks.
2fill in blank
medium

Complete the code to modify post content using a filter.

Wordpress
add_filter('the_content', '[1]');
Drag options to blanks, or click blank then click option'
Awp_footer
Benqueue_scripts
Cmodify_content
Dadmin_init
Attempts:
3 left
💡 Hint
Common Mistakes
Using a hook name instead of a function name.
Passing a WordPress hook name instead of a function.
3fill in blank
hard

Fix the error in this code that tries to add an action.

Wordpress
add_action('wp_footer', [1]);
Drag options to blanks, or click blank then click option'
A'wp_footer'
Bfooter_function()
Cwp_footer
D'footer_function'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling the function instead of passing its name.
Passing the hook name instead of the function name.
4fill in blank
hard

Fill both blanks to add a filter that changes the title and set priority to 10.

Wordpress
add_filter('[1]', '[2]', 10);
Drag options to blanks, or click blank then click option'
Athe_title
Bmodify_title
Cthe_content
Dchange_title
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up content and title filters.
Using function names that don't exist.
5fill in blank
hard

Fill all three blanks to add an action with a callback and priority 20.

Wordpress
add_action('[1]', '[2]', [3]);
Drag options to blanks, or click blank then click option'
Awp_enqueue_scripts
Bload_scripts
C20
Dinit
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong hook names for scripts.
Passing priority as a string instead of a number.