{"id":5037,"date":"2023-02-14T09:57:39","date_gmt":"2023-02-14T15:57:39","guid":{"rendered":"https:\/\/wpengine.com\/builders\/?p=5037"},"modified":"2023-12-13T10:56:00","modified_gmt":"2023-12-13T16:56:00","slug":"what-are-block-variations","status":"publish","type":"post","link":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/","title":{"rendered":"What Are Block Variations and How to Use Them"},"content":{"rendered":"\n<p>It is crucial to become familiar with different ways to compose with WordPress blocks. Should you use a block pattern? Template part? Or, even a block variation? What about a block style?<\/p>\n\n\n\n<p>Today, we&#8217;re going to focus on <strong>block variations,<\/strong> but will also compare and contrast with <strong>block styles<\/strong> to give you an overview of the differences.<\/p>\n\n\n\n<div class=\"wp-block-group has-polar-background-color has-background has-global-padding is-layout-constrained wp-container-core-group-is-layout-2a9f3359 wp-block-group-is-layout-constrained\" style=\"padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--40)\">\n<p class=\"has-large-font-size\" style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\"><strong>Table of contents<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\" style=\"margin-top:var(--wp--preset--spacing--30);margin-right:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30);margin-left:var(--wp--preset--spacing--30)\">\n<li><a href=\"#overview\">Overview of block variations<\/a><\/li>\n\n\n\n<li><a href=\"#comparing-block-styles-variations\">Comparing block styles and block variations<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#block-styles\">Block styles<\/a><\/li>\n\n\n\n<li><a href=\"#block-variations\">Block variations<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#adding-block-variations\">Adding block variations to a custom block<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#register-unregister-block-variations\">Register or unregister block variations<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#block-variation-examples\">Block variation examples<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#search-block-variation\">Example: Search block variation for a custom post type<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#conclusion\">Conclusion and further reading<\/a><\/li>\n<\/ul>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"overview\">Overview of block variations<\/h2>\n\n\n\n<p><strong>Block variations<\/strong> are a means to extend an existing block&#8217;s <a href=\"https:\/\/developer.wordpress.org\/block-editor\/reference-guides\/block-api\/block-attributes\/\" target=\"_blank\" rel=\"noreferrer noopener\">attributes<\/a> and <a href=\"https:\/\/gutenberg.10up.com\/training\/inner-blocks\/\">inner blocks<\/a> to create a unique variation. <\/p>\n\n\n\n<p>A common example of an existing WordPress block variation is the Embed block, which has numerous variations of the same functionality for embedding different providers, e.g. YouTube, Twitter, and Facebook. The Embed block leverages a custom <code>providerNameSlug<\/code> attribute to differentiate each embed&#8217;s icon and other attributes.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized is-style-border\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/embed-block-variations.png\" alt=\"Block selection sidebar with Embed block highlighted\" class=\"wp-image-5045\" width=\"333\" height=\"441\" srcset=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/embed-block-variations.png 666w, https:\/\/wpengine.com\/builders\/wp-content\/uploads\/embed-block-variations-227x300.png 227w\" sizes=\"auto, (max-width: 333px) 100vw, 333px\" \/><figcaption class=\"wp-element-caption\">Block selection sidebar with Embed block and its many variations<\/figcaption><\/figure>\n\n\n\n<p>Before we go any further, it is important to distinguish between block <strong>styles<\/strong> and block <strong>variations<\/strong>. Below is an overview of the differences.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-left\" id=\"comparing-block-styles-variations\" style=\"line-height:1.5\">Comparing <mark style=\"background-color:#f4f7fa\" class=\"has-inline-color\">block styles<\/mark> and <mark style=\"background-color:#f4f7fa\" class=\"has-inline-color\">block variations<\/mark><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"block-styles\"><strong>Block styles<\/strong><\/h3>\n\n\n\n<p>Used to assign a custom selector (e.g. <code>.is-style-blue-list<\/code>) and custom appearance to an existing block. Typically ideal if you need to just modify an existing block with some custom CSS.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Possible <strong>benefits<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Easy API to introduce a simple CSS variant<\/li>\n\n\n\n<li>Gives a distinguishable UI for editors to glance at and choose a variation<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Possible <strong>downsides &amp; pitfalls<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Be careful not to introduce too many block styles.\n<ul class=\"wp-block-list\">\n<li>Each style will require CSS, which can quickly become unscaleable<\/li>\n\n\n\n<li>Each style offers another option for an editor to have to choose from, which can quickly become overwhelming<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full is-style-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1075\" height=\"872\" src=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/image-block-styles-example.gif\" alt=\"Example of Image block styles in editor\" class=\"wp-image-5039\"\/><figcaption class=\"wp-element-caption\">Image block with Default and Round block styles<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-medium-large-font-size\" id=\"block-variations\"><strong>Block variations<\/strong><\/h3>\n\n\n\n<p>Used to extend an existing block&#8217;s attributes and even inner blocks.<\/p>\n\n\n\n<p>It is possible to override the default block style by passing the <code>className<\/code> attribute when creating a block variation.<\/p>\n\n\n\n<p>Where block styles might be used to modify a block&#8217;s feel and appearance; block variations can do that and much more by modifying the substance of the block, and even its inner blocks.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Possible <strong>benefits<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Introduce a single new attribute to an existing block<\/li>\n\n\n\n<li>Multiple ways to surface in the UI of the editor: <code>inserter<\/code>, <code>block<\/code>, <code>transform<\/code> (more on this below)<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Possible <strong>downsides &amp; pitfalls<\/strong><\/h4>\n\n\n\n<p>Be careful with how many block variations you&#8217;re introducing. While the Embed block has dozens of block variations it can become unwieldy and you may want to consider creating a unique, new block if you&#8217;re introducing too many block variations to a core block.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-border\"><img loading=\"lazy\" decoding=\"async\" width=\"681\" height=\"473\" src=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/columns-block-variations.png\" alt=\"Columns block options for block variations with inserter\" class=\"wp-image-5040\" srcset=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/columns-block-variations.png 681w, https:\/\/wpengine.com\/builders\/wp-content\/uploads\/columns-block-variations-300x208.png 300w\" sizes=\"auto, (max-width: 681px) 100vw, 681px\" \/><figcaption class=\"wp-element-caption\">Columns block options for block variations with the inserter<\/figcaption><\/figure>\n\n\n\n<p>Hopefully, that helps give you some guidance to choose between whether to customize a block with a <strong>variation<\/strong> or a block <strong>style<\/strong>.<\/p>\n\n\n\n<p>Now let&#8217;s focus on how you can register, unregister, and even some common use cases for block variations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"adding-block-variations\">Adding block variations to a custom block<\/h2>\n\n\n\n<p>You can pass the <code>variation<\/code> object when a block is registered to assign an array of fields. Here is an example from the Embed block:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span>variations: &#91;\n<\/span><\/span><span class='shcb-loc'><span>    {\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">name<\/span>: <span class=\"hljs-string\">'wordpress'<\/span>,\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">isDefault<\/span>: <span class=\"hljs-literal\">true<\/span>,\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">title<\/span>: __( <span class=\"hljs-string\">'WordPress'<\/span> ),\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">description<\/span>: __( <span class=\"hljs-string\">'Code is poetry!'<\/span> ),\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">icon<\/span>: WordPressIcon,\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">attributes<\/span>: { <span class=\"hljs-attr\">providerNameSlug<\/span>: <span class=\"hljs-string\">'wordpress'<\/span> },\n<\/span><\/span><span class='shcb-loc'><span>    },\n<\/span><\/span><span class='shcb-loc'><span>    {\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">name<\/span>: <span class=\"hljs-string\">'google'<\/span>,\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">title<\/span>: __( <span class=\"hljs-string\">'Google'<\/span> ),\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">icon<\/span>: GoogleIcon,\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">attributes<\/span>: { <span class=\"hljs-attr\">providerNameSlug<\/span>: <span class=\"hljs-string\">'google'<\/span> },\n<\/span><\/span><span class='shcb-loc'><span>    },\n<\/span><\/span><span class='shcb-loc'><span>    {\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">name<\/span>: <span class=\"hljs-string\">'twitter'<\/span>,\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">title<\/span>: __( <span class=\"hljs-string\">'Twitter'<\/span> ),\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">icon<\/span>: TwitterIcon,\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">attributes<\/span>: { <span class=\"hljs-attr\">providerNameSlug<\/span>: <span class=\"hljs-string\">'twitter'<\/span> },\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attr\">keywords<\/span>: &#91; __(<span class=\"hljs-string\">'tweet'<\/span>) ],\n<\/span><\/span><span class='shcb-loc'><span>    },\n<\/span><\/span><span class='shcb-loc'><span>],\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>An object describing a variation defined for the block type can contain the following fields:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>name<\/code>&nbsp;(type&nbsp;<code>string<\/code>) \u2013 The unique and machine-readable name.<\/li>\n\n\n\n<li><code>title<\/code>&nbsp;(type&nbsp;<code>string<\/code>) \u2013 A human-readable variation title.<\/li>\n\n\n\n<li><code>description<\/code>&nbsp;(optional, type&nbsp;<code>string<\/code>) \u2013 A detailed variation description.<\/li>\n\n\n\n<li><code>category<\/code>&nbsp;(optional, type&nbsp;<code>string<\/code>) &#8211; A category classification, used in search interfaces to arrange block types by category.<\/li>\n\n\n\n<li><code>icon<\/code>&nbsp;(optional, type&nbsp;<code>string<\/code>&nbsp;|&nbsp;<code>Object<\/code>) \u2013 An icon helping to visualize the variation. It can have the same shape as the block type.<\/li>\n\n\n\n<li><code>isDefault<\/code>&nbsp;(optional, type&nbsp;<code>boolean<\/code>) \u2013 Indicates whether the current variation is the default one. Defaults to&nbsp;<code>false<\/code>.<\/li>\n\n\n\n<li><code>attributes<\/code>&nbsp;(optional, type&nbsp;<code>Object<\/code>) \u2013 Values that override block attributes.<\/li>\n\n\n\n<li><code>innerBlocks<\/code>&nbsp;(optional, type&nbsp;<code>Array[]<\/code>) \u2013 Initial configuration of nested blocks.<\/li>\n\n\n\n<li><code>example<\/code>&nbsp;(optional, type&nbsp;<code>Object<\/code>) \u2013 Example provides structured data for the block preview. You can set to&nbsp;<code>undefined<\/code>&nbsp;to disable the preview shown for the block type.<\/li>\n\n\n\n<li><code>scope<\/code>&nbsp;(optional, type&nbsp;<code>WPBlockVariationScope[]<\/code>) &#8211; the list of scopes where the variation is applicable. When not provided, it defaults to&nbsp;<code>block<\/code>&nbsp;and&nbsp;<code>inserter<\/code>. Available options:\n<ul class=\"wp-block-list\">\n<li><code>inserter<\/code>&nbsp;&#8211; Block Variation is shown on the inserter.<\/li>\n\n\n\n<li><code>block<\/code>&nbsp;&#8211; Used by blocks to filter specific block variations.&nbsp;<code>Columns<\/code>&nbsp;and&nbsp;<code>Query Loop<\/code>&nbsp;blocks have such variations and are passed to the&nbsp;<a href=\"https:\/\/github.com\/WordPress\/gutenberg\/blob\/HEAD\/packages\/block-editor\/src\/components\/block-variation-picker\/README.md\" target=\"_blank\" rel=\"noreferrer noopener\">experimental BlockVariationPicker<\/a>&nbsp;component, which is handling the displaying of variations and the ability to select one from them.<\/li>\n\n\n\n<li><code>transform<\/code>&nbsp;&#8211; Block Variation will be shown in the component for Block Variations transformations.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><code>keywords<\/code>&nbsp;(optional, type&nbsp;<code>string[]<\/code>) &#8211; An array of terms (which can be translated) that help users discover the variation while searching.<\/li>\n\n\n\n<li><code>isActive<\/code>&nbsp;(optional, type&nbsp;<code>Function|string[]<\/code>) &#8211; This can be a function or an array of block attributes. A function that accepts a block&#8217;s attributes and the variation&#8217;s attributes and determines if a variation is active. This function doesn&#8217;t try to find a match dynamically based on all block&#8217;s attributes, as in many cases some attributes are irrelevant. An example would be for the&nbsp;<code>embed<\/code>&nbsp;block where we only care about the&nbsp;providerNameSlug&nbsp;attribute&#8217;s value. We can also use a&nbsp;string[]&nbsp;to tell which attributes should be compared as a shorthand. Each attribute will be matched and the variation will be active if all of them are matching.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"register-unregister-block-variations\">Register or unregister block variations<\/h3>\n\n\n\n<p>You can register a block variation for an existing block with <code>registerBlockVariation()<\/code>. This can be useful if you need to extend the Columns block to support a layout that does not exist but is useful to your client or editorial team. (More use cases below)<\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-container-core-group-is-layout-d6743c7d wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group has-polar-background-color has-background is-content-justification-center is-nowrap is-layout-flex wp-container-core-group-is-layout-e84a4744 wp-block-group-is-layout-flex\" style=\"padding-top:10px;padding-right:var(--wp--preset--spacing--20);padding-bottom:10px;padding-left:var(--wp--preset--spacing--20)\">\n<p class=\"has-small-font-size\">Example of how to <strong>register<\/strong> a block variation for an existing block<\/p>\n<\/div>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span>wp.blocks.registerBlockVariation( <span class=\"hljs-string\">'core\/embed'<\/span>, {\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attr\">name<\/span>: <span class=\"hljs-string\">'custom'<\/span>,\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attr\">attributes<\/span>: { <span class=\"hljs-attr\">providerNameSlug<\/span>: <span class=\"hljs-string\">'custom'<\/span> },\n<\/span><\/span><span class='shcb-loc'><span>} );\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre><\/div>\n\n\n\n<p>You can unregister an existing block variation with <code>unregisterBlockVariation()<\/code>. This could be useful to streamline and refine the options that your client or editorial team is presented with, especially when it comes to the Embed block.<\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-container-core-group-is-layout-d6743c7d wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group has-polar-background-color has-background is-content-justification-center is-nowrap is-layout-flex wp-container-core-group-is-layout-931901aa wp-block-group-is-layout-flex\" style=\"padding-top:10px;padding-bottom:10px\">\n<p class=\"has-small-font-size\">Example of how to <strong>unregister<\/strong> an existing block variation<\/p>\n<\/div>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span>wp.blocks.unregisterBlockVariation( <span class=\"hljs-string\">'core\/embed'<\/span>, <span class=\"hljs-string\">'youtube'<\/span> );\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre><\/div>\n\n\n\n<p>In both registering and unregistering a block variation you&#8217;ll need to reference the block slug, which is <code>core\/embed<\/code> for the Embed block in the examples above.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-variation-examples\">Block variation examples<\/h2>\n\n\n\n<p>Some common use cases for using block variations include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Custom Search block variation for custom post types and taxonomies<\/li>\n\n\n\n<li>Custom Columns block variation for missing column split<\/li>\n<\/ul>\n\n\n\n<p>Let&#8217;s check out an example of how to extend the Search block to return results for a custom post type.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"search-block-variation\">Example: Search block variation for a custom post type<\/h3>\n\n\n\n<p>By default, the Search block allows for the <code>query<\/code> attribute to be passed as an object, which can be useful if you want to refine the search results to only return results for a custom post type or taxonomy.<\/p>\n\n\n\n<p>Let&#8217;s say we had a Podcast post type and we want to have a search form available on the podcast landing page. We only want that search to return results for the Podcast post type.<\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-container-core-group-is-layout-d6743c7d wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group has-polar-background-color has-background is-content-justification-center is-nowrap is-layout-flex wp-container-core-group-is-layout-e84a4744 wp-block-group-is-layout-flex\" style=\"padding-top:10px;padding-right:var(--wp--preset--spacing--20);padding-bottom:10px;padding-left:var(--wp--preset--spacing--20)\">\n<p class=\"has-small-font-size\">Example of extending the Search block to query for the podcast post type<\/p>\n<\/div>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span>wp.blocks.registerBlockVariation( <span class=\"hljs-string\">'core\/search'<\/span>, {\n<\/span><\/span><span class='shcb-loc'><span>\t<span class=\"hljs-attr\">name<\/span>: <span class=\"hljs-string\">'wpe-example\/podcast-search'<\/span>,\n<\/span><\/span><span class='shcb-loc'><span>\t<span class=\"hljs-attr\">title<\/span>: <span class=\"hljs-string\">'Podcast Search'<\/span>,\n<\/span><\/span><span class='shcb-loc'><span>\t<span class=\"hljs-attr\">attributes<\/span>: {\n<\/span><\/span><span class='shcb-loc'><span>\t\t<span class=\"hljs-attr\">query<\/span>: {\n<\/span><\/span><span class='shcb-loc'><span>\t\t\t<span class=\"hljs-attr\">post_type<\/span>: <span class=\"hljs-string\">'podcast'<\/span>\n<\/span><\/span><span class='shcb-loc'><span>\t\t}\n<\/span><\/span><span class='shcb-loc'><span>\t}\n<\/span><\/span><span class='shcb-loc'><span>} );\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre><\/div>\n\n\n\n<p>With the above code implemented, we can now search and add the new Podcast Search block variation (of the Search block) into our new podcast page, and voila.<\/p>\n\n\n\n<figure class=\"wp-block-image alignwide size-full is-style-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1388\" height=\"996\" src=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/podcast-search-example.gif\" alt=\"Adding custom Podcast Search block variation in editor\" class=\"wp-image-5044\"\/><figcaption class=\"wp-element-caption\">Adding custom Podcast Search block variation in the editor<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion and further reading<\/h2>\n\n\n\n<p>The block-building world can often feel overwhelming with options. Hopefully, I&#8217;ve given you enough detail to navigate the decision-making that can go into composing and extending with block variations in WordPress.<\/p>\n\n\n\n<p>Have you been exploring using these techniques and want to share? Don&#8217;t be shy and reach out on <a href=\"https:\/\/twitter.com\/dcook\" target=\"_blank\" rel=\"noreferrer noopener\">Twitter<\/a> if you want to share or have any questions.<\/p>\n\n\n\n<div class=\"wp-block-group has-polar-background-color has-background has-global-padding is-layout-constrained wp-container-core-group-is-layout-2a9f3359 wp-block-group-is-layout-constrained\" style=\"padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--40)\">\n<p class=\"has-medium-large-font-size\" style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\"><strong>Further reading<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\" style=\"margin-top:var(--wp--preset--spacing--30);margin-right:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30);margin-left:var(--wp--preset--spacing--30)\">\n<li><a href=\"https:\/\/developer.wordpress.org\/block-editor\/reference-guides\/block-api\/block-variations\/\" target=\"_blank\" rel=\"noreferrer noopener\">WordPress.org \u2013 Developer Resources: Block API Reference &gt; Variations<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/fullsiteediting.com\/lessons\/block-variations\/\" target=\"_blank\" rel=\"noreferrer noopener\">FullSiteEditing.com \u2013 Block variations<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/gutenberg.10up.com\/reference\/Blocks\/block-variations\/\" target=\"_blank\" rel=\"noreferrer noopener\">10up \u2013 Gutenberg Best Practices: Block variations<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Learn the differences between block styles and block variations and how to use variations in customer and core blocks.<\/p>\n","protected":false},"author":11,"featured_media":5038,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_EventAllDay":false,"_EventTimezone":"","_EventStartDate":"","_EventEndDate":"","_EventStartDateUTC":"","_EventEndDateUTC":"","_EventShowMap":false,"_EventShowMapLink":false,"_EventURL":"","_EventCost":"","_EventCostDescription":"","_EventCurrencySymbol":"","_EventCurrencyCode":"","_EventCurrencyPosition":"","_EventDateTimeSeparator":"","_EventTimeRangeSeparator":"","_EventOrganizerID":[],"_EventVenueID":[],"_OrganizerEmail":"","_OrganizerPhone":"","_OrganizerWebsite":"","_VenueAddress":"","_VenueCity":"","_VenueCountry":"","_VenueProvince":"","_VenueState":"","_VenueZip":"","_VenuePhone":"","_VenueURL":"","_VenueStateProvince":"","_VenueLat":"","_VenueLng":"","_VenueShowMap":false,"_VenueShowMapLink":false,"footnotes":""},"categories":[1],"tags":[16,17,43],"class_list":["post-5037","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-block-builders","tag-block-variations","tag-popular-2023"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What Are Block Variations and How to Use Them - Builders<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wpengine.com\/builders\/what-are-block-variations\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What Are Block Variations and How to Use Them - Builders\" \/>\n<meta property=\"og:description\" content=\"Learn the differences between block styles and block variations and how to use variations in customer and core blocks.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wpengine.com\/builders\/what-are-block-variations\/\" \/>\n<meta property=\"og:site_name\" content=\"Builders\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-14T15:57:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-13T16:56:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/block-variations-og.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Damon Cook\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/block-variations-og.jpg\" \/>\n<meta name=\"twitter:creator\" content=\"@dcook\" \/>\n<meta name=\"twitter:site\" content=\"@wpebuilders\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Damon Cook\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/what-are-block-variations\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/what-are-block-variations\\\/\"},\"author\":{\"name\":\"Damon Cook\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#\\\/schema\\\/person\\\/9d8d20c8a321b90faceae588fcf6d30d\"},\"headline\":\"What Are Block Variations and How to Use Them\",\"datePublished\":\"2023-02-14T15:57:39+00:00\",\"dateModified\":\"2023-12-13T16:56:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/what-are-block-variations\\\/\"},\"wordCount\":1319,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/what-are-block-variations\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/block-variations.jpg\",\"keywords\":[\"block builders\",\"block variations\",\"popular-2023\"],\"articleSection\":[\"WordPress\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wpengine.com\\\/builders\\\/what-are-block-variations\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/what-are-block-variations\\\/\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/what-are-block-variations\\\/\",\"name\":\"What Are Block Variations and How to Use Them - Builders\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/what-are-block-variations\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/what-are-block-variations\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/block-variations.jpg\",\"datePublished\":\"2023-02-14T15:57:39+00:00\",\"dateModified\":\"2023-12-13T16:56:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/what-are-block-variations\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wpengine.com\\\/builders\\\/what-are-block-variations\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/what-are-block-variations\\\/#primaryimage\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/block-variations.jpg\",\"contentUrl\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/block-variations.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/what-are-block-variations\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What Are Block Variations and How to Use Them\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#website\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/\",\"name\":\"Builders\",\"description\":\"Reimagining the way we build with WordPress.\",\"publisher\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#organization\",\"name\":\"WP Engine\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/WP-Engine-Horizontal@2x.png\",\"contentUrl\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/WP-Engine-Horizontal@2x.png\",\"width\":348,\"height\":68,\"caption\":\"WP Engine\"},\"image\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/wpebuilders\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCh1WuL54XFb9ZI6m6goFv1g\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#\\\/schema\\\/person\\\/9d8d20c8a321b90faceae588fcf6d30d\",\"name\":\"Damon Cook\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/18d75285d6803fab88b7f45601bb68cbac7c3956347217c06a0291e27dc65f6a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/18d75285d6803fab88b7f45601bb68cbac7c3956347217c06a0291e27dc65f6a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/18d75285d6803fab88b7f45601bb68cbac7c3956347217c06a0291e27dc65f6a?s=96&d=mm&r=g\",\"caption\":\"Damon Cook\"},\"description\":\"Damon Cook is a Developer Advocate at WP Engine. Previously, he navigated the WordPress agency land for a decade. He is a purveyor and discoverer of musical frisson. He can be found in the realms of WordPress Slack, WooCommerce Slack, and Twitter.\",\"sameAs\":[\"https:\\\/\\\/x.com\\\/dcook\"],\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/author\\\/damon-cook\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What Are Block Variations and How to Use Them - Builders","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/","og_locale":"en_US","og_type":"article","og_title":"What Are Block Variations and How to Use Them - Builders","og_description":"Learn the differences between block styles and block variations and how to use variations in customer and core blocks.","og_url":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/","og_site_name":"Builders","article_published_time":"2023-02-14T15:57:39+00:00","article_modified_time":"2023-12-13T16:56:00+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/block-variations-og.jpg","type":"image\/jpeg"}],"author":"Damon Cook","twitter_card":"summary_large_image","twitter_image":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/block-variations-og.jpg","twitter_creator":"@dcook","twitter_site":"@wpebuilders","twitter_misc":{"Written by":"Damon Cook","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/#article","isPartOf":{"@id":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/"},"author":{"name":"Damon Cook","@id":"https:\/\/wpengine.com\/builders\/#\/schema\/person\/9d8d20c8a321b90faceae588fcf6d30d"},"headline":"What Are Block Variations and How to Use Them","datePublished":"2023-02-14T15:57:39+00:00","dateModified":"2023-12-13T16:56:00+00:00","mainEntityOfPage":{"@id":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/"},"wordCount":1319,"commentCount":0,"publisher":{"@id":"https:\/\/wpengine.com\/builders\/#organization"},"image":{"@id":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/#primaryimage"},"thumbnailUrl":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/block-variations.jpg","keywords":["block builders","block variations","popular-2023"],"articleSection":["WordPress"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wpengine.com\/builders\/what-are-block-variations\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/","url":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/","name":"What Are Block Variations and How to Use Them - Builders","isPartOf":{"@id":"https:\/\/wpengine.com\/builders\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/#primaryimage"},"image":{"@id":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/#primaryimage"},"thumbnailUrl":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/block-variations.jpg","datePublished":"2023-02-14T15:57:39+00:00","dateModified":"2023-12-13T16:56:00+00:00","breadcrumb":{"@id":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wpengine.com\/builders\/what-are-block-variations\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/#primaryimage","url":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/block-variations.jpg","contentUrl":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/block-variations.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/wpengine.com\/builders\/what-are-block-variations\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wpengine.com\/builders\/"},{"@type":"ListItem","position":2,"name":"What Are Block Variations and How to Use Them"}]},{"@type":"WebSite","@id":"https:\/\/wpengine.com\/builders\/#website","url":"https:\/\/wpengine.com\/builders\/","name":"Builders","description":"Reimagining the way we build with WordPress.","publisher":{"@id":"https:\/\/wpengine.com\/builders\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wpengine.com\/builders\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/wpengine.com\/builders\/#organization","name":"WP Engine","url":"https:\/\/wpengine.com\/builders\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wpengine.com\/builders\/#\/schema\/logo\/image\/","url":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2024\/05\/WP-Engine-Horizontal@2x.png","contentUrl":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2024\/05\/WP-Engine-Horizontal@2x.png","width":348,"height":68,"caption":"WP Engine"},"image":{"@id":"https:\/\/wpengine.com\/builders\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/wpebuilders","https:\/\/www.youtube.com\/channel\/UCh1WuL54XFb9ZI6m6goFv1g"]},{"@type":"Person","@id":"https:\/\/wpengine.com\/builders\/#\/schema\/person\/9d8d20c8a321b90faceae588fcf6d30d","name":"Damon Cook","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/18d75285d6803fab88b7f45601bb68cbac7c3956347217c06a0291e27dc65f6a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/18d75285d6803fab88b7f45601bb68cbac7c3956347217c06a0291e27dc65f6a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/18d75285d6803fab88b7f45601bb68cbac7c3956347217c06a0291e27dc65f6a?s=96&d=mm&r=g","caption":"Damon Cook"},"description":"Damon Cook is a Developer Advocate at WP Engine. Previously, he navigated the WordPress agency land for a decade. He is a purveyor and discoverer of musical frisson. He can be found in the realms of WordPress Slack, WooCommerce Slack, and Twitter.","sameAs":["https:\/\/x.com\/dcook"],"url":"https:\/\/wpengine.com\/builders\/author\/damon-cook\/"}]}},"_links":{"self":[{"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/posts\/5037","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/comments?post=5037"}],"version-history":[{"count":0,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/posts\/5037\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/media\/5038"}],"wp:attachment":[{"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/media?parent=5037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/categories?post=5037"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/tags?post=5037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}