Skip to content

Shortcode & block

[stacko_form id="123"]
Attribute Type Description
id int, required Form ID
class string One extra CSS class added to the form wrapper (passed through sanitize_html_class())
[stacko_form id="123" class="my-contact-form"]

Attributes can be filtered with WordPress’s shortcode_atts_stacko_form filter.

Property Value
Name stacko/form
Title Stacko Form
Category widgets
Attributes formId (number, default 0)
Supports align (wide, full), spacing.margin; html: false
Rendering Dynamic (server-side render_callback; save() returns null)

Block markup in post content:

<!-- wp:stacko/form {"formId":123} /-->

The block output is the same form HTML as the shortcode, wrapped in a <div> with the block wrapper attributes (alignment, margin, custom class). With formId set to 0 the block renders nothing.

The editor UI lists forms through GET /stacko-forms/v1/forms, so users without the stacko_forms_manage capability see a notice instead of the form picker.

The shortcode and block both call the renderer. In a theme or plugin, render a form with do_shortcode():

echo do_shortcode( '[stacko_form id="123"]' );
  • Only published forms render. For a draft, trashed or missing form, visitors get an empty string and users with stacko_forms_manage get a short notice.
  • The same form can appear more than once on a page. Each copy gets its own instance number, and DOM IDs follow the pattern sf-form-{formId}-{instance} for the form and sf-{formId}-{instance}-{fieldId} for fields.
  • Front-end JS and CSS are enqueued only when a form is actually rendered. The stylesheet can be turned off globally with Stacko Forms → Settings → Advanced → Load form styles.
  • The HTML contains no WordPress nonce, so it’s safe to serve from a full-page cache. A signed token is embedded, and the script fetches a fresh one from GET /stacko-forms/v1/token/{id} on the first focusin.

The <form> posts to admin-post.php with action=stacko_forms_submit. After processing, the visitor is redirected back to the referring page with an sf_r query parameter and a #sf-form-{id}-{instance} fragment. The form then shows the success message, or the errors and the visitor’s previous input. If the form’s confirmation is a page or URL redirect, the visitor goes straight there.

With JavaScript, the form is submitted to POST /stacko-forms/v1/submit/{id} instead and errors are shown inline without a reload.

When Give this form its own page is turned on in the builder’s Share tab (the form_page setting), the published form is available at:

https://example.com/?stacko_form=123

The page outputs wp_head() and wp_footer() so theme styles load, but it doesn’t use a theme template. It works the same with block and classic themes. It sends noindex unless you change that with the stacko_forms_index_form_page filter. If the form isn’t published or the setting is off, the URL returns a 404.

The <body> gets the class stacko-forms-page, the content is wrapped in <main class="sf-page"> with an <h1 class="sf-page__title">.

Admins can preview the current draft inside the theme at /?stacko_forms_preview={id}&_wpnonce={nonce}. The link is created by the builder and requires stacko_forms_manage and a valid nonce for that form. The page sends no-cache headers and noindex.

Every selector in the front-end stylesheet is wrapped in :where(), so it has zero specificity and any theme rule wins. Most styling goes through CSS custom properties on the wrapper:

Property Purpose
--sf-accent Accent colour (button, focus, checked states)
--sf-radius Corner radius
--sf-gap Space between fields
--sf-text Text colour
--sf-muted Help text colour
--sf-bg Field background
--sf-border Field border colour
--sf-error Error colour
--sf-focus Focus ring (a full box-shadow value, not just a colour)
--sf-control-height Height of single-line inputs

The accent and radius chosen in the builder’s Style tab are set as inline --sf-accent and --sf-radius on the wrapper.

/* Make every Stacko form match your brand. */
.sf-wrap {
--sf-accent: #0b6e4f;
--sf-radius: 4px;
--sf-gap: 1.25rem;
}

Useful classes:

Class Element
.sf-wrap Outer wrapper; also gets .sf-preset-{inherit|clean|soft|bold} and .sf-labels-{top|left}
.sf-form The <form> element
.sf-row, .sf-cols-{n} A layout row with n fields
.sf-field, .sf-field--{type} A field wrapper; .sf-field--invalid and .sf-field--required when applicable
.sf-label, .sf-help, .sf-error, .sf-input Label, help text, error message, input control
.sf-error-summary The error summary shown on submit
.sf-submit The submit button
.sf-confirmation The success message