Overview
What It's For
The Button block lets editors place a styled call-to-action button anywhere in a page or post. Beyond simple text links, it handles the full range of button destinations — internal pages and posts, external URLs, email addresses, and phone numbers — all configured through editor controls without touching any code.
Why Reach for This Block
The core WordPress editor's button block covers basic links, but Button goes further in two important ways. First, it integrates with the site's post and content library directly: you can point a button at any published post, page, or custom post type by choosing from dropdown lists, so the link stays correct even if the URL changes. Second, it exposes the theme's full button style system — visual style variants and the site's color palette — through the block inspector, keeping buttons visually consistent with the design system without requiring CSS knowledge.
Key Capabilities
- Four visual style variants — filled, hollow, chip, and naked — selectable from the block sidebar
- Theme color palette — button color chosen from the site's top-level color tokens, ensuring on-brand output
- Internal link picker — select any post type, then pick a specific post or page from a live dropdown; attachment files open in a new tab automatically
- External link modes — supports full URLs,
mailto:email addresses, andtel:phone numbers, each with its own input field - New-tab control — toggle whether external links open in a new browser tab (on by default)
- Margin spacing controls — per-side or global margin adjustments using the theme's standard spacing scale (none, quarter, half, base, double, triple), configured in the "Spacing" panel of the block sidebar
DOM Structure
<!-- block renders nothing when no href is resolved -->
<!-- when 'Link is external URL' is unchecked and no internal post is selected, or -->
<!-- when 'Link is external URL' is checked and no URL/email/phone is entered, -->
<!-- the <a> tag is suppressed entirely -->
<a class="button {buttonColor} {buttonType}" <!-- buttonColor = theme color slug, buttonType = filled|hollow|chip|naked -->
href="{resolvedHref}" <!-- see link resolution notes below -->
style="{spacingStyles}" <!-- margin values from Spacing panel; no padding applied to this block -->
target="_blank"> <!-- when 'Link is external URL' + 'Open in new tab' are both on, -->
<!-- OR when linked post type is a media attachment -->
{buttonText}
</a>
<!-- Link href resolution (mutually exclusive): -->
<!-- when 'Link is external URL' is unchecked: href = permalink of selected internal post/page/CPT, -->
<!-- or wp_get_attachment_url() when post type is 'attachment' -->
<!-- when 'Link is external URL' is checked and 'Destination' is 'webpage': href = entered URL -->
<!-- when 'Link is external URL' is checked and 'Destination' is 'email': href = mailto:{emailAddress} -->
<!-- when 'Link is external URL' is checked and 'Destination' is 'phone': href = tel:{digitsOnly} -->DOM Notes
No dynamic regions.
Technical Documentation
Canvas Controls
The Button block exposes its primary link configuration directly on the editor canvas (outside the sidebar inspector), making it immediately visible and editable without opening any panel.
Button (text field)
- Attribute:
text - Type: Text input field
- Default: Empty
What it controls — The visible label that appears on the rendered button element on the front end.
Notes — Displayed as a labeled text input at the top of the canvas block. If left empty, the button renders with a single space as its label; the button itself will not appear on the front end unless a valid link destination is also configured.
Link is external URL
- Attribute:
hrefIsExternal - Type: Checkbox
- Default:
false(unchecked)
What it controls — Switches the button between two link modes. When unchecked, the button links to an internal page or post selected from WordPress content. When checked, the button links to an external destination (URL, email address, or phone number) typed in manually.
Options
- Unchecked — Shows the internal post-type picker workflow (see below).
- Checked — Reveals the "Open in new tab" checkbox and the "Destination" dropdown.
Open in new tab
- Attribute:
openExternalInNewTab - Type: Checkbox
- Default:
true(checked)
What it controls — When enabled, the rendered button anchor tag carries target="_blank", opening the linked destination in a new browser tab.
Conditional Logic — Visible only when "Link is external URL" is checked.
Notes — Attachment (file) links always open in a new tab regardless of this setting.
Destination
- Attribute:
linkType - Type: Single-select dropdown
- Default:
webpage
What it controls — Determines which type of external link the button points to, changing which text-entry field appears below it on the canvas.
Options
- webpage — Shows a URL text field; the entered value is used directly as the
href. - email — Shows an email address text field; renders as a
mailto:link on the front end. - phone — Shows a phone number text field; strips all non-numeric characters and renders as a
tel:link on the front end.
Conditional Logic — Visible only when "Link is external URL" is checked.
URL / Email / Phone input field
- Attributes:
externalUrl·emailAddress·phoneNumber - Type: Text input field (one shown at a time, depending on Destination)
- Default: Empty string for each
What it controls — The actual destination address for the external link. Which field appears depends on the selected Destination:
- webpage — Enter the full URL including
https://. - email — Enter a valid email address (e.g.
[email protected]); rendered asmailto:. - phone — Enter a local or international phone number; non-numeric characters are stripped before rendering as
tel:.
Conditional Logic — Each field is visible only when "Link is external URL" is checked and the matching Destination option is selected.
Post type selector (internal link — post type)
- Attribute:
linkPostType - Type: Single-select dropdown
- Default: Empty (no selection)
What it controls — Selects which content type to browse when linking internally. Available post types are populated from the site's registered post types (sourced from fc_data.post_type_options). Choosing a post type reveals a second dropdown listing individual posts of that type.
Conditional Logic — Visible only when "Link is external URL" is unchecked.
Notes — The "custom" and "child-pages" post type values are excluded from the list. The "attachment" post type (media files) is included and handled separately — selecting an attachment causes the front-end link to use the file's direct URL and always opens in a new tab.
Post / item selector (internal link — specific item)
- Attribute:
linkPostId - Type: Single-select dropdown
- Default:
0(no selection)
What it controls — Selects the specific post, page, or media file to link to. The rendered button's href resolves to that item's permalink (or, for attachments, its direct file URL).
Conditional Logic — Visible only when "Link is external URL" is unchecked and a post type has been selected in the post type selector above. The dropdown is populated with published and private entries of the chosen post type, sorted alphabetically by title.
Block Settings
Type
- Attribute:
buttonType - Type: Single-select dropdown
- Default:
filled - Panel: Style
What it controls — Applies a CSS class to the rendered button that controls its visual style treatment.
Options
- filled — Solid background button using the selected color.
- hollow — Outlined/border-only button; background is transparent.
- chip — Compact pill/chip style button.
- naked — No background or border; appears as styled text link.
Color
- Attribute:
buttonColor - Type: Color palette (swatch picker, theme colors only; no custom colors, no alpha)
- Default:
primary - Panel: Style
What it controls — Sets the color class applied to the button element, controlling its background (for filled), border (for hollow), or text color (for naked/chip) on the front end. The rendered class is derived from the selected theme color token.
Options — Swatches are drawn from the site's top-level theme color tokens (defined in Theme Options / the styleguide via fc_data.theme_colors). Custom color entry and transparency are both disabled.
Spacing
- Attribute:
spacing - Type: Grouped spacing controls (toggles + single-select dropdowns)
- Default: All margin values inherit from theme; all padding sides disabled for this block
- Panel: Spacing
What it controls — Applies inline margin styles to the button's wrapper element, overriding theme defaults on a per-side or global basis. Padding controls are disabled for the Button block — only margin controls are active.
The Spacing panel contains the following controls:
Margin
- Fine Tune Margin (toggle) — When off, a single global margin dropdown sets the same value on all four sides. When on, four individual dropdowns appear for Margin Top, Margin Bottom, Margin Left, and Margin Right.
- Global Margin / Margin Top / Margin Bottom / Margin Left / Margin Right — Each is a single-select dropdown with the following options:
- Inherit from theme — Uses the theme's default spacing variable (no inline override).
- None — Sets margin to
0. - Quarter —
calc(var(--base-spacing) * 0.25) - Half —
calc(var(--base-spacing) * 0.5) - BASE —
calc(var(--base-spacing)) - Double —
calc(var(--base-spacing) * 2) - Triple —
calc(var(--base-spacing) * 3)
Cross-Block Relationships
The Button block is a standalone block with no required parent or required child blocks. It can be placed inside any block that accepts inner blocks, such as column blocks or layout containers.
Theme-Level Integrations
Color palette population
The swatches available in the Color picker (Style panel) are driven entirely by the theme's registered color tokens, exposed via fc_data.theme_colors. Only top-level color names are shown (e.g. primary, secondary, neutral) — not individual tonal stops. The set of available color choices therefore changes automatically when Theme Options color definitions are updated, without requiring any per-block configuration.