Recall & Review
beginner
What is a shortcode in WordPress?
A shortcode is a small piece of code in square brackets that you can add to posts or pages to insert dynamic content easily without writing full code.
Click to reveal answer
beginner
How do you register a shortcode in WordPress?
You use the
add_shortcode() function, giving it a name and a callback function that returns the content to display.Click to reveal answer
beginner
What does the callback function for a shortcode do?
It runs when the shortcode is used and returns the content that replaces the shortcode in the post or page.
Click to reveal answer
intermediate
How can you pass attributes to a shortcode?
You define parameters in the callback function and use the
shortcode_atts() function to set default values and get user input.Click to reveal answer
intermediate
Why should shortcode output be returned, not echoed?
Because WordPress expects the shortcode function to return content as a string to insert it properly, echoing can break page layout or cause errors.
Click to reveal answer
Which function registers a shortcode in WordPress?
✗ Incorrect
The correct function to register a shortcode is add_shortcode().
What should a shortcode callback function do?
✗ Incorrect
Shortcode callbacks must return content as a string, not echo it.
How do you provide default attribute values in a shortcode?
✗ Incorrect
shortcode_atts() merges user attributes with defaults.
Where do you place shortcode tags in WordPress?
✗ Incorrect
Shortcodes are placed inside post or page content to display dynamic content.
What does [gallery] represent in WordPress?
✗ Incorrect
[gallery] is a built-in shortcode to show image galleries.
Explain how to create a simple shortcode in WordPress that outputs 'Hello, friend!'
Think about the function that connects shortcode name to output.
You got /4 concepts.
Describe how to add attributes to a shortcode and use them inside the callback function.
Attributes let users customize shortcode output.
You got /4 concepts.