Bird
Raised Fist0
Wordpressframework~10 mins

Gutenberg block editor basics in Wordpress - Step-by-Step Execution

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Concept Flow - Gutenberg block editor basics
Open Post/Page Editor
Click + to Add Block
Select Block Type
Block Inserted in Content
Edit Block Content
Save or Publish Post/Page
This flow shows how you open the editor, add a block, edit it, and save your content.
Execution Sample
Wordpress
1. Click '+' button
2. Choose 'Paragraph' block
3. Type text inside block
4. Click 'Save' button
This sequence adds a paragraph block, types text, and saves the post.
Execution Table
StepActionEditor StateBlock Added/EditedResult
1Open editorEmpty content or existing content loadedNo block added yetEditor ready for editing
2Click '+' to add blockShows block inserter panelNo block added yetBlock inserter visible
3Select 'Paragraph' blockBlock inserter closesParagraph block inserted at cursorBlank paragraph block appears
4Type 'Hello World!'Paragraph block content updatedParagraph block text setText visible inside block
5Click 'Save'Content saved to databaseAll blocks savedPost updated with new content
6Exit editorEditor closesContent remains savedPost ready for viewing
💡 User finishes editing and saves content, editor closes
Variable Tracker
VariableStartAfter Step 3After Step 4After Step 5Final
Content"""<p></p>""<p>Hello World!</p>""<p>Hello World!</p>""<p>Hello World!</p>"
Block Inserter Visiblefalsetruefalsefalsefalse
Editor Opentruetruetruetruefalse
Key Moments - 3 Insights
Why does the block inserter panel close after selecting a block?
After selecting a block (see Step 3 in execution_table), the inserter closes to show the block inserted in the content area for editing.
What happens if you type text before adding a block?
You cannot type text before adding a block because the editor requires a block to hold content. See Step 3 and 4 where the paragraph block is inserted first.
Does saving immediately publish the post?
Saving updates the post content but does not necessarily publish it. Publishing is a separate action. Step 5 shows content saved, but publishing depends on post status.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the editor state after Step 2?
AParagraph block inserted
BBlock inserter panel is visible
CContent saved to database
DEditor closed
💡 Hint
Check the 'Editor State' column for Step 2 in execution_table
At which step does the paragraph block get inserted into the content?
AStep 4
BStep 1
CStep 3
DStep 5
💡 Hint
Look at the 'Block Added/Edited' column in execution_table
If you typed text before adding a block, how would the variable 'Content' change after Step 3?
AIt would remain empty
BIt would contain the typed text
CIt would contain a blank paragraph block
DIt would cause an error
💡 Hint
Refer to key_moments about typing text before adding a block and variable_tracker for 'Content'
Concept Snapshot
Gutenberg block editor basics:
- Click '+' to add a block
- Choose block type (e.g., Paragraph)
- Edit block content directly
- Save or publish your post
Blocks are content containers making editing flexible and visual.
Full Transcript
The Gutenberg block editor lets you build content by adding blocks. First, you open the editor for a post or page. Then you click the plus button to open the block inserter panel. You select a block type, like a paragraph, which inserts a blank block into your content. You type your text inside this block. When done, you click save to store your changes. The editor closes when you exit, keeping your content safe. Blocks help organize content visually and make editing easier.

Practice

(1/5)
1. What is the main purpose of Gutenberg blocks in WordPress?
easy
A. To build content visually by stacking pieces called blocks
B. To write PHP code for themes
C. To manage user roles and permissions
D. To create database tables

Solution

  1. Step 1: Understand Gutenberg blocks concept

    Gutenberg blocks allow users to build content visually by stacking blocks instead of writing code.
  2. Step 2: Compare options with this concept

    Options A, B, and D relate to other WordPress functions, not content building with blocks.
  3. Final Answer:

    To build content visually by stacking pieces called blocks -> Option A
  4. Quick Check:

    Gutenberg blocks = Visual content building [OK]
Hint: Blocks stack visually to build content, not code or settings [OK]
Common Mistakes:
  • Confusing blocks with coding PHP
  • Thinking blocks manage users or database
  • Mixing blocks with theme development
2. Which of the following is the correct way to define the edit function in a custom Gutenberg block?
easy
A. function edit() {

Hello Block

; }
B. def edit(): return '

Hello Block

'
C. edit = function() { echo 'Hello Block'; }
D. const edit = () => { return

Hello Block

; };

Solution

  1. Step 1: Identify JavaScript syntax for Gutenberg blocks

    Gutenberg blocks use modern JavaScript with arrow functions for edit.
  2. Step 2: Check each option's syntax

    const edit = () => { return <p>Hello Block</p>; }; uses arrow function returning JSX, which is correct. function edit() { <p>Hello Block</p>; } does not return the JSX element. edit = function() { echo 'Hello Block'; } uses PHP syntax, and B uses Python syntax, both invalid here.
  3. Final Answer:

    const edit = () => { return <p>Hello Block</p>; }; -> Option D
  4. Quick Check:

    Gutenberg edit uses JS arrow functions [OK]
Hint: Gutenberg edit uses JavaScript arrow functions returning JSX [OK]
Common Mistakes:
  • Using PHP or Python syntax instead of JavaScript
  • Not returning JSX properly
  • Using old function syntax without React import
3. Given this simple block edit function, what will be rendered in the editor?
const edit = () => {
return <p>Welcome to Gutenberg!</p>;
};
medium
A. A paragraph with text 'Welcome to Gutenberg!'
B. An empty block with no content
C. A syntax error preventing rendering
D. A button labeled 'Welcome to Gutenberg!'

Solution

  1. Step 1: Analyze the edit function return value

    The function returns a paragraph element with the text 'Welcome to Gutenberg!'.
  2. Step 2: Understand editor rendering behavior

    The editor shows the returned JSX content, so a paragraph with that text appears.
  3. Final Answer:

    A paragraph with text 'Welcome to Gutenberg!' -> Option A
  4. Quick Check:

    JSX return = paragraph text shown [OK]
Hint: JSX returned in edit shows as block content in editor [OK]
Common Mistakes:
  • Thinking it renders a button
  • Assuming syntax error without checking code
  • Expecting empty content when JSX is returned
4. What is wrong with this Gutenberg block save function?
const save = () => {
<div>Saved content</div>;
};
medium
A. save function should be async
B. Using <div> instead of <p> tag
C. Missing return statement in the save function
D. save function cannot use JSX

Solution

  1. Step 1: Check function syntax for returning JSX

    The save function has JSX but no return statement, so it returns undefined.
  2. Step 2: Understand save function requirements

    Save must return JSX to render saved content; missing return causes no output.
  3. Final Answer:

    Missing return statement in the save function -> Option C
  4. Quick Check:

    JSX must be returned in save function [OK]
Hint: Always return JSX in save function to render content [OK]
Common Mistakes:
  • Forgetting return keyword
  • Thinking tag choice causes error
  • Assuming save must be async
5. You want to create a custom Gutenberg block that shows a user-editable heading and paragraph. Which two functions must you define to make this block work properly?
hard
A. registerBlockType and enqueueScripts only
B. edit and save functions to handle editing and saving content
C. PHP render callback and CSS styles only
D. enqueueScripts and enqueueStyles only

Solution

  1. Step 1: Identify core Gutenberg block functions

    Every block needs an edit function to show editing UI and a save function to define saved content.
  2. Step 2: Compare options with required functions

    edit and save functions to handle editing and saving content correctly lists edit and save. Other options mention scripts or PHP but miss these core functions.
  3. Final Answer:

    edit and save functions to handle editing and saving content -> Option B
  4. Quick Check:

    Blocks need edit + save functions [OK]
Hint: Blocks always need edit and save functions [OK]
Common Mistakes:
  • Thinking only scripts or PHP are enough
  • Forgetting save function
  • Confusing enqueueing scripts with block logic