Recall & Review
beginner
What is an enclosing shortcode in WordPress?
An enclosing shortcode is a shortcode that wraps content between an opening and closing tag, like [shortcode]content[/shortcode]. It allows you to modify or display the content inside it.
Click to reveal answer
beginner
How do you define an enclosing shortcode in WordPress PHP code?
You define a function that accepts attributes and content, then register it with add_shortcode. The function uses the $content parameter to access the enclosed content.
Click to reveal answer
intermediate
What happens if you omit the closing tag in an enclosing shortcode?
The shortcode will not treat the content as enclosed. It will only process the opening tag, and the content after it will not be passed to the shortcode function.
Click to reveal answer
beginner
Example: What does this shortcode do? [bold]Hello[/bold]
If 'bold' is an enclosing shortcode that wraps content in tags, it will output: Hello making the text bold.
Click to reveal answer
intermediate
Why use enclosing shortcodes instead of self-closing ones?
Enclosing shortcodes let you apply effects or formatting to the content inside them, giving more flexibility than self-closing shortcodes which only output fixed content.Click to reveal answer
Which of these is an example of an enclosing shortcode?
✗ Incorrect
Only [button]Click me[/button] has both opening and closing tags, enclosing content.
In a shortcode function, which parameter holds the enclosed content?
✗ Incorrect
The $content parameter contains the content between the shortcode tags.
What will happen if you forget the closing tag in an enclosing shortcode?
✗ Incorrect
Without the closing tag, the content is not passed to the shortcode function.
How do you register a shortcode in WordPress?
✗ Incorrect
add_shortcode is the WordPress function to register shortcodes.
Which is a benefit of enclosing shortcodes?
✗ Incorrect
Enclosing shortcodes let you wrap and change the content inside them.
Explain how enclosing shortcodes work in WordPress and how you create one.
Think about how you wrap content and how the function receives it.
You got /4 concepts.
Describe a real-life example where enclosing shortcodes would be useful.
Imagine you want to make text bold or add a special style.
You got /3 concepts.