Screening Entry Level

What are shortcodes in WordPress? How do you create one, and when should you use a shortcode versus a block?

Quick Tip

Show the transition: "Shortcodes work everywhere and are simple to implement — add_shortcode with a callback that returns HTML. For new features, I prefer custom blocks because users get a visual preview. But shortcodes are still the right choice for dynamic content in places blocks cannot reach."

What good answers include

Shortcodes are bracketed tags like [gallery] that WordPress replaces with dynamic content. Register with add_shortcode(tag, callback) — the callback receives attributes and optional enclosed content, and returns HTML. Self-closing: [button url="/"]. Enclosing: [highlight]text[/highlight]. Shortcodes predate the block editor and are still widely used in plugins. When to use blocks instead: blocks provide a visual editing experience with a live preview, which is better for most use cases. Shortcodes are still appropriate for: backwards compatibility, simple inline dynamic content, and contexts where the block editor is not available (widgets, text areas, custom fields). Strong candidates mention: that shortcodes should always return output (not echo it), the do_shortcode() function for processing shortcodes in custom locations, and that the block editor has a Shortcode block for embedding shortcodes.

What interviewers are looking for

Entry-level WordPress question. Candidates who cannot create a basic shortcode lack fundamental plugin development skills. Those who also understand when blocks are a better choice show awareness of the evolving WordPress landscape.

← All WordPress questions