0
0
Wordpressframework~10 mins

Reading and writing settings 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 read a WordPress option named 'site_name'.

Wordpress
$site_name = get_option([1]);
Drag options to blanks, or click blank then click option'
Asite_name
B'site_name'
C'get_site_name'
Dsite_name()
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the option name
Using a function call instead of a string
2fill in blank
medium

Complete the code to update the WordPress option 'background_color' with the value '#ffffff'.

Wordpress
update_option([1], '#ffffff');
Drag options to blanks, or click blank then click option'
A'background_color'
Bbackground_color
C'background-color'
DbackgroundColor
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without quotes
Using camelCase instead of the exact option name
3fill in blank
hard

Fix the error in the code to properly add a new option 'footer_text' with value 'Thank you!'.

Wordpress
add_option([1], 'Thank you!');
Drag options to blanks, or click blank then click option'
AfooterText
B'footer-text'
Cfooter_text
D'footer_text'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing option name without quotes
Using incorrect option name format
4fill in blank
hard

Fill both blanks to read the option 'header_text' and provide a default value 'Welcome!'.

Wordpress
$header = get_option([1], [2]);
Drag options to blanks, or click blank then click option'
A'header_text'
B'Welcome!'
CWelcome!
Dheader_text
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the default value
Using variable names instead of strings
5fill in blank
hard

Fill all three blanks to update the option 'footer_color' only if the new value '#000000' is different from the current one.

Wordpress
if (get_option([1]) !== [2]) {
    update_option([3], '#000000');
}
Drag options to blanks, or click blank then click option'
A'footer_color'
B'#000000'
D'#ffffff'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting option names or values
Using different strings for option names