Challenge - 5 Problems
Custom Plugin Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Why create a custom plugin instead of using existing ones?
Which reason best explains why a developer would create a custom WordPress plugin instead of using an existing plugin?
Attempts:
2 left
💡 Hint
Think about unique features and specific needs that off-the-shelf plugins might not cover.
✗ Incorrect
Custom plugins allow developers to build features tailored exactly to a website's unique requirements, which existing plugins may not provide.
❓ component_behavior
intermediate2:00remaining
How does a custom plugin affect WordPress site behavior?
If a custom plugin adds a new shortcode to display a special message, what will happen when the shortcode is used in a post?
Attempts:
2 left
💡 Hint
Think about what shortcodes do when registered by plugins.
✗ Incorrect
When a plugin registers a shortcode, WordPress replaces the shortcode with the output defined by the plugin, such as a special message.
📝 Syntax
advanced2:00remaining
Identify the correct way to register a custom plugin's shortcode
Which code snippet correctly registers a shortcode named 'greet' that outputs 'Hello, visitor!'?
Attempts:
2 left
💡 Hint
Remember the WordPress function name and whether the callback should return or echo.
✗ Incorrect
The correct function to register a shortcode is add_shortcode, and the callback must return the output string, not echo it.
🔧 Debug
advanced2:00remaining
Why does this custom plugin shortcode not display output?
A developer wrote this shortcode registration:
add_shortcode('welcome', function() { echo 'Welcome!'; });
Why does the shortcode [welcome] show nothing on the page?
Attempts:
2 left
💡 Hint
Think about how WordPress processes shortcode output.
✗ Incorrect
Shortcode callbacks must return their output as a string. Using echo sends output directly and results in no content replacement.
❓ state_output
expert3:00remaining
What is the output after activating this custom plugin?
Consider this plugin code:
If a post contains the shortcode [counter] three times, what will be the output shown in the post?
Attempts:
2 left
💡 Hint
Consider how static variables inside functions behave during multiple calls.
✗ Incorrect
The static variable $count keeps its value between calls, so each shortcode call increments it, producing increasing counts.