Skip to main content

How To Create A Block In WordPress

a
adminWordPress

As a beginner, you might be wondering how to create a block in WordPress. The scattered elements and block section might confuse you.

But do you have to worry if you get guidance on how to easily add a custom block to your WordPress website?

I don’t think so!

The methods are simple and easy. All you have to know is what it is, why it is and how you can do it. 

Let’s get started.

What Is WordPress Blocks?

WordPress blocks are like building blocks for your website. They’re individual pieces of content or features that you can easily add, move, and customize in the WordPress Block Editor.

Blocks let you work with different elements instead of dealing with a single large chunk of text. Elements such as paragraphs, images, buttons, and more make creating and designing your web pages simpler.

They give you the flexibility to arrange and style your content how you want without needing to be a coding expert. WordPress blocks make it easy for anyone to create and customize their website without the technical hassle.

how to create a block in WordPress

How To Create A Block In WordPress?

Creating a custom block in WordPress is like making a special content section that you can use and reuse easily. Here’s a simple guide to do it:

Go to Your WordPress Site

Log in to your WordPress website.

-

Access the Block Editor

Open the post or page where you want to add the custom block. Click on the “+” icon to open the block editor.

how to create a block in WordPress

Choose a Block Type

Look for the “Custom HTML” or “Custom” block type. Click on it to add it to your post or page.

-

Add Your Content

Once you’ve added the custom block, you can put your special content inside. This could be text, images, or anything you want.

how to create a block in WordPress

Customize Your Block

You might see options to change how your block looks. This could be colors, fonts, or other settings. Play around with them until you like how it looks.

Preview And Save

Before making it live, you can preview your post to see how your custom block will appear to your visitors. Once you’re happy with your custom block, save your changes.

-

Publish Your Post

If you’re ready for the world to see your post with the custom block, click “Publish” or “Update”.

-

Why Create A Custom WordPress Block?

WordPress has a handy editor that lets you build your posts and pages easily by adding different elements, like text or images, as blocks.

By default, WordPress gives you some common blocks to use. If you install plugins, they might add even more blocks for you to choose from.

But sometimes, you might want to make a special block for something specific on your website. Maybe the blocks you find don’t quite do what you need them to do.

Custom blocks let you add special features to your website that you can’t get with the regular blocks. This can make things easier when you’re creating content for your WordPress blog.

Start Creating Block In WordPress NOW!

Creating a block in WordPress is pretty straightforward.

You can use different types of built-in blocks to make your website more dynamic. 

And if you are a coder or pro, you can be creative with a Custom HTML block.

And if you want to learn how to add Google Maps with WordPress Block Editor, here is the link!

Frequently Asked Questions

														<span class="bdt-ep-accordion-icon bdt-flex-align-right"
								aria-hidden="true">

																		<span class="bdt-ep-accordion-icon-closed">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-plus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
																		<span class="bdt-ep-accordion-icon-opened">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-minus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
							</span>
						
						<span role="heading" class="bdt-ep-title-text bdt-flex-inline bdt-flex-middle" >

															Can I Add Styling To My Custom Block?							</span>

					</div>
					<div class="bdt-ep-accordion-content bdt-accordion-content">
						<p><span style="font-weight: 400;">Yes, you can add styling to your custom block using the </span><b>&#8220;Additional CSS Class&#8221; </b><span style="font-weight: 400;">option in the block settings or by applying inline styles directly within the</span><b> &#8220;Custom HTML&#8221; </b><span style="font-weight: 400;">block.</span></p>						</div>
				</div>
								<div class="bdt-ep-accordion-item">
					<div							class="bdt-ep-accordion-title bdt-accordion-title bdt-flex bdt-flex-middle bdt-flex-between" id="bdt-ep-accordion-what-if-i-want-a-more-advanced-and-interactive-custom-block"
						data-accordion-index="1" data-title="what-if-i-want-a-more-advanced-and-interactive-custom-block">

														<span class="bdt-ep-accordion-icon bdt-flex-align-right"
								aria-hidden="true">

																		<span class="bdt-ep-accordion-icon-closed">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-plus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
																		<span class="bdt-ep-accordion-icon-opened">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-minus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
							</span>
						
						<span role="heading" class="bdt-ep-title-text bdt-flex-inline bdt-flex-middle" >

															What If I Want A More Advanced And Interactive Custom Block?							</span>

					</div>
					<div class="bdt-ep-accordion-content bdt-accordion-content">
						<p><span style="font-weight: 400;">For more advanced features and interactivity, it&#8217;s recommended to create a custom block using JavaScript, HTML, and CSS. This involves coding, and you may want to consider seeking assistance from a developer or using plugins that offer pre-built blocks.</span></p>						</div>
				</div>
								<div class="bdt-ep-accordion-item">
					<div							class="bdt-ep-accordion-title bdt-accordion-title bdt-flex bdt-flex-middle bdt-flex-between" id="bdt-ep-accordion-should-i-create-a-custom-block-in-a-theme-or-a-plugin"
						data-accordion-index="2" data-title="should-i-create-a-custom-block-in-a-theme-or-a-plugin">

														<span class="bdt-ep-accordion-icon bdt-flex-align-right"
								aria-hidden="true">

																		<span class="bdt-ep-accordion-icon-closed">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-plus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
																		<span class="bdt-ep-accordion-icon-opened">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-minus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
							</span>
						
						<span role="heading" class="bdt-ep-title-text bdt-flex-inline bdt-flex-middle" >

															Should I Create A Custom Block In A Theme Or A Plugin?							</span>

					</div>
					<div class="bdt-ep-accordion-content bdt-accordion-content">
						<p><span style="font-weight: 400;">It&#8217;s generally recommended to create a custom block within a plugin for modularity and flexibility. This way, the custom block functionality remains intact even if you switch themes.</span></p>						</div>
				</div>
								<div class="bdt-ep-accordion-item">
					<div							class="bdt-ep-accordion-title bdt-accordion-title bdt-flex bdt-flex-middle bdt-flex-between" id="bdt-ep-accordion-how-do-i-enqueue-styles-and-scripts-for-my-custom-block"
						data-accordion-index="3" data-title="how-do-i-enqueue-styles-and-scripts-for-my-custom-block">

														<span class="bdt-ep-accordion-icon bdt-flex-align-right"
								aria-hidden="true">

																		<span class="bdt-ep-accordion-icon-closed">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-plus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
																		<span class="bdt-ep-accordion-icon-opened">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-minus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
							</span>
						
						<span role="heading" class="bdt-ep-title-text bdt-flex-inline bdt-flex-middle" >

															How Do I Enqueue Styles And Scripts For My Custom Block?							</span>

					</div>
					<div class="bdt-ep-accordion-content bdt-accordion-content">
						<p><span style="font-weight: 400;">In your theme&#8217;s functions.php file or your plugin file, you can use the wp_enqueue_script and wp_enqueue_style functions to load the JavaScript and CSS files for your custom block.</span></p>						</div>
				</div>
								<div class="bdt-ep-accordion-item">
					<div							class="bdt-ep-accordion-title bdt-accordion-title bdt-flex bdt-flex-middle bdt-flex-between" id="bdt-ep-accordion-can-i-preview-my-custom-block-before-publishing"
						data-accordion-index="4" data-title="can-i-preview-my-custom-block-before-publishing">

														<span class="bdt-ep-accordion-icon bdt-flex-align-right"
								aria-hidden="true">

																		<span class="bdt-ep-accordion-icon-closed">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-plus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
																		<span class="bdt-ep-accordion-icon-opened">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-minus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
							</span>
						
						<span role="heading" class="bdt-ep-title-text bdt-flex-inline bdt-flex-middle" >

															Can I Preview My Custom Block Before Publishing?							</span>

					</div>
					<div class="bdt-ep-accordion-content bdt-accordion-content">
						<p><span style="font-weight: 400;">Yes, you can preview your custom block by previewing the post or page in the WordPress editor. This allows you to see how your custom block looks before making it live.</span></p>						</div>
				</div>
								<div class="bdt-ep-accordion-item">
					<div							class="bdt-ep-accordion-title bdt-accordion-title bdt-flex bdt-flex-middle bdt-flex-between" id="bdt-ep-accordion-can-i-reuse-my-custom-block-on-different-pages-or-posts"
						data-accordion-index="5" data-title="can-i-reuse-my-custom-block-on-different-pages-or-posts">

														<span class="bdt-ep-accordion-icon bdt-flex-align-right"
								aria-hidden="true">

																		<span class="bdt-ep-accordion-icon-closed">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-plus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
																		<span class="bdt-ep-accordion-icon-opened">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-minus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
							</span>
						
						<span role="heading" class="bdt-ep-title-text bdt-flex-inline bdt-flex-middle" >

															Can I Reuse My Custom Block On Different Pages Or Posts?							</span>

					</div>
					<div class="bdt-ep-accordion-content bdt-accordion-content">
						<p><span style="font-weight: 400;">Yes, once you&#8217;ve created a custom block, you can easily reuse it on different pages or posts by adding the block from the Gutenberg editor&#8217;s block inserter.</span></p>						</div>
				</div>
								<div class="bdt-ep-accordion-item">
					<div							class="bdt-ep-accordion-title bdt-accordion-title bdt-flex bdt-flex-middle bdt-flex-between" id="bdt-ep-accordion-are-there-plugins-that-offer-pre-built-custom-blocks"
						data-accordion-index="6" data-title="are-there-plugins-that-offer-pre-built-custom-blocks">

														<span class="bdt-ep-accordion-icon bdt-flex-align-right"
								aria-hidden="true">

																		<span class="bdt-ep-accordion-icon-closed">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-plus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
																		<span class="bdt-ep-accordion-icon-opened">
										<svg aria-hidden="true" class="fa-fw e-font-icon-svg e-fas-minus" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>										</span>
								
							</span>
						
						<span role="heading" class="bdt-ep-title-text bdt-flex-inline bdt-flex-middle" >

															Are There Plugins That Offer Pre-Built Custom Blocks?							</span>

					</div>
					<div class="bdt-ep-accordion-content bdt-accordion-content">
						<p><span style="font-weight: 400;">Yes, there are plugins available in the WordPress repository that provide a variety of pre-built custom blocks. These plugins can be installed and activated to extend the functionality of the Gutenberg editor.</span></p>						</div>
				</div>
						</div>
	</div>
					</div>
				</div>
			</div>
			</div>
a

admin

The BdThemes team builds WordPress plugins trusted by 3M+ users worldwide. We write about web accessibility, WCAG compliance, and inclusive design.