Custom Gutenberg Blocks Development for WordPress

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1212
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    815

Developing Custom Gutenberg Blocks for WordPress

Gutenberg replaced TinyMCE as the primary WordPress editor in version 5.0. Custom blocks are React components that render both in the editor and on the frontend. They give editors visual control over structured content without needing to know HTML. Development of one medium-complexity block takes 2–4 days.

Block Registration

The modern approach uses block.json + JavaScript/PHP:

{
  "$schema": "https://schemas.wp.org/trunk/block.json",
  "apiVersion": 3,
  "name": "my-plugin/project-card",
  "version": "1.0.0",
  "title": "Project Card",
  "category": "common",
  "icon": "portfolio",
  "description": "Displays a portfolio project card with image and description",
  "supports": {
    "html": false,
    "align": ["wide", "full"],
    "color": { "background": true, "text": true }
  },
  "attributes": {
    "projectId": { "type": "number" },
    "showDescription": { "type": "boolean", "default": true },
    "imageSize": { "type": "string", "default": "large" }
  },
  "editorScript": "file:./index.js",
  "editorStyle": "file:./editor.css",
  "style": "file:./style.css"
}

PHP registration:

add_action('init', function () {
    register_block_type(__DIR__ . '/blocks/project-card');
});

JavaScript: edit and save

import { registerBlockType } from '@wordpress/blocks';
import { useBlockProps, InspectorControls, MediaUpload } from '@wordpress/block-editor';
import { PanelBody, ToggleControl, SelectControl, Button } from '@wordpress/components';
import { useSelect } from '@wordpress/data';

registerBlockType('my-plugin/project-card', {
  edit: ({ attributes, setAttributes }) => {
    const { projectId, showDescription, imageSize } = attributes;
    const blockProps = useBlockProps({ className: 'project-card-editor' });

    const projects = useSelect(select =>
      select('core').getEntityRecords('postType', 'project', { per_page: 50 })
    );

    const projectOptions = projects
      ? [{ label: '— select project —', value: 0 }, ...projects.map(p => ({ label: p.title.rendered, value: p.id }))]
      : [{ label: 'Loading...', value: 0 }];

    return (
      <>
        <InspectorControls>
          <PanelBody title="Block Settings">
            <SelectControl
              label="Project"
              value={projectId}
              options={projectOptions}
              onChange={v => setAttributes({ projectId: Number(v) })}
            />
            <ToggleControl
              label="Show description"
              checked={showDescription}
              onChange={v => setAttributes({ showDescription: v })}
            />
            <SelectControl
              label="Image size"
              value={imageSize}
              options={[
                { label: 'Thumbnail', value: 'thumbnail' },
                { label: 'Medium', value: 'medium' },
                { label: 'Large', value: 'large' },
              ]}
              onChange={v => setAttributes({ imageSize: v })}
            />
          </PanelBody>
        </InspectorControls>
        <div {...blockProps}>
          {projectId
            ? <ProjectCardPreview projectId={projectId} showDescription={showDescription} />
            : <p>Select a project in the panel on the right</p>
          }
        </div>
      </>
    );
  },

  save: () => null, // dynamic block — render via PHP
});

save: () => null means the block is dynamic—content is rendered by PHP when the page is requested. This is preferable for blocks whose data changes (posts from the database).

PHP Rendering of Dynamic Block

register_block_type(__DIR__ . '/blocks/project-card', [
    'render_callback' => 'my_plugin_render_project_card',
]);

function my_plugin_render_project_card(array $attributes): string {
    $project_id      = absint($attributes['projectId'] ?? 0);
    $show_desc       = (bool) ($attributes['showDescription'] ?? true);
    $image_size      = sanitize_key($attributes['imageSize'] ?? 'large');

    if (!$project_id) return '';

    $project = get_post($project_id);
    if (!$project || $project->post_status !== 'publish') return '';

    $thumbnail = get_the_post_thumbnail($project_id, $image_size, ['class' => 'project-card__image']);
    $title     = esc_html($project->post_title);
    $permalink = esc_url(get_permalink($project_id));
    $excerpt   = $show_desc ? '<p class="project-card__desc">' . esc_html(get_the_excerpt($project)) . '</p>' : '';

    $wrapper_attributes = get_block_wrapper_attributes(['class' => 'project-card']);

    return "<article {$wrapper_attributes}>
        {$thumbnail}
        <h3 class=\"project-card__title\"><a href=\"{$permalink}\">{$title}</a></h3>
        {$excerpt}
    </article>";
}

get_block_wrapper_attributes() adds classes from supports.color and other attributes that Gutenberg generates automatically.

Block with innerBlocks

Container blocks accept child blocks via InnerBlocks:

import { InnerBlocks } from '@wordpress/block-editor';

const ALLOWED_BLOCKS = ['core/paragraph', 'core/heading', 'my-plugin/cta-button'];
const TEMPLATE = [
  ['core/heading', { level: 3, placeholder: 'Section heading' }],
  ['core/paragraph', { placeholder: 'Description...' }],
  ['my-plugin/cta-button', {}],
];

// In edit:
<InnerBlocks allowedBlocks={ALLOWED_BLOCKS} template={TEMPLATE} templateLock={false} />

// In save:
<InnerBlocks.Content />

Build

Blocks are built via @wordpress/scripts:

{
  "scripts": {
    "build": "wp-scripts build",
    "start": "wp-scripts start",
    "lint:js": "wp-scripts lint-js"
  },
  "devDependencies": {
    "@wordpress/scripts": "^27.0.0"
  }
}

wp-scripts is configured for WordPress by default: it knows @wordpress/* as external dependencies, generates asset.php with version hash for proper cache invalidation.

Extending Existing Blocks via Filters

You don't always need a new block—sometimes adding an attribute or panel to an existing one is enough:

import { addFilter } from '@wordpress/hooks';
import { createHigherOrderComponent } from '@wordpress/compose';

// Add "data-section" attribute to any block
addFilter('blocks.registerBlockType', 'my-plugin/add-section-id', (settings) => {
  settings.attributes = {
    ...settings.attributes,
    sectionId: { type: 'string', default: '' },
  };
  return settings;
});

// Add field to InspectorControls
const withSectionIdControl = createHigherOrderComponent(BlockEdit => {
  return (props) => {
    const { attributes, setAttributes } = props;
    return (
      <>
        <BlockEdit {...props} />
        <InspectorControls>
          <PanelBody title="Anchor Link">
            <TextControl
              label="Section ID"
              value={attributes.sectionId}
              onChange={v => setAttributes({ sectionId: v })}
            />
          </PanelBody>
        </InspectorControls>
      </>
    );
  };
}, 'withSectionIdControl');

addFilter('editor.BlockEdit', 'my-plugin/section-id-control', withSectionIdControl);

Typical Timelines

Simple static block with 2–3 attributes: 4–8 hours. Dynamic block with PHP render and settings panel: 1–2 days. Container block with innerBlocks, custom styling, and server-side render: 2–4 days. Set of 5–10 related blocks for design system: from 2 weeks.