Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a hook that runs too late like 'the_content'.
Confusing action hooks with filter hooks.
✗ Incorrect
The init hook runs early in WordPress loading, perfect for initialization tasks.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a hook name instead of a function name.
Passing a WordPress hook name instead of a function.
✗ Incorrect
The function modify_content will be called to change the post content before display.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling the function instead of passing its name.
Passing the hook name instead of the function name.
✗ Incorrect
The function name must be passed as a string without parentheses.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up content and title filters.
Using function names that don't exist.
✗ Incorrect
The the_title filter changes post titles, and modify_title is the function that modifies it.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong hook names for scripts.
Passing priority as a string instead of a number.
✗ Incorrect
This adds an action on wp_enqueue_scripts to run load_scripts with priority 20.