Bird
0
0

You want to create a shortcode [alert type="error"] that wraps content and shows it with a red background. Which is the best way to write the enclosing shortcode usage?

hard📝 state output Q15 of 15
Wordpress - Shortcodes and Blocks
You want to create a shortcode [alert type="error"] that wraps content and shows it with a red background. Which is the best way to write the enclosing shortcode usage?
A<code>[alert type="error"]Warning!</alert></code>
B<code>[alert type="error" /]Warning!</code>
C<code>[alert]Warning![/alert type="error"]</code>
D<code>[alert type="error"]Warning![/alert]</code>
Step-by-Step Solution
Solution:
  1. Step 1: Confirm enclosing shortcode syntax with attributes

    The opening tag includes attributes inside square brackets, e.g., [alert type="error"].
  2. Step 2: Verify matching closing tag

    The closing tag must be [/alert] exactly, no attributes allowed there.
  3. Step 3: Evaluate options

    [alert type="error"]Warning![/alert] correctly uses [alert type="error"]Warning![/alert]. [alert type="error" /]Warning! is self-closing and incorrect for enclosing content. [alert]Warning![/alert type="error"] misplaces attribute in closing tag. [alert type="error"]Warning! has incorrect closing tag syntax.
  4. Final Answer:

    [alert type="error"]Warning![/alert] -> Option D
  5. Quick Check:

    Attributes in opening tag, proper closing tag = A [OK]
Quick Trick: Attributes go in opening tag; closing tag has no attributes [OK]
Common Mistakes:
  • Using self-closing syntax for enclosing shortcodes
  • Placing attributes in closing tag
  • Incorrect closing tag format

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes