Main/WordPress Fullstack/Blueprints/Gutenberg & FSE/Dynamic Block with Server-Side Rendering (render.php)
Back to «Gutenberg & FSE» cards
Gutenberg & FSE(ТЗ 29 из 54)
Spec: Dynamic Block with Server-Side Rendering (render.php)
Gutenberg & FSE5 шагов • +25 XP

Spec: Dynamic Block with Server-Side Rendering (render.php)

Building dynamic WordPress blocks with real-time server queries: render.php rendering, WP_Query optimization, transient caching, editor preview placeholder, and block attributes synchronization.

~8 ч работыУровень: Middle@wordpress/scriptsblock.json v3render.phpServerSideRenderWP_QueryTransient CacheInspectorControls
+5 XP за шаг
Выполнено 0 из 5 шагов (0%)
Трудозатраты~8 рабочих часов
Фриланс вилка~$360 – $600 (€320 – €560)
Оценка веб-студии~$760 – $1,280 (€720 – €1200)

ТЗ заказчика (исходный бриф):

We need a 'Latest Courses / Case Studies Grid' block that always displays the freshest content without requiring editors to re-save the page. It must render server-side in PHP and update instantly when new posts are published.
Ключевые требования:
  • •Server-side dynamic block rendering via render.php (no static HTML in post_content)
  • •Configurable attributes in block.json: postType, categories, numberOfPosts, columns
  • •Live editor preview using ServerSideRender or lightweight React placeholder
  • •High-performance database query caching via Transients API with automatic invalidation
  • •Semantic markup with responsive CSS grid and schema markup
Ограничения проекта:
  • •Strict database performance: 0 unindexed queries on large databases (100k+ posts)
  • •Seamless fallback if no posts match query parameters
Критерии приёмки (KPI):
  • Server execution time for render.php < 25ms (cached)
  • Zero post_content bloat in wp_posts table
  • Editor preview matches frontend output with 100% fidelity

Конфигурация блупринта под условия проекта

Выберите архитектуру и стек — шаги роадмапа, структура файлов и примеры кода переключатся автоматически:

Пошаговое практическое руководство по ТЗ

Подробный разбор архитектуры, код реализации и советы эксперта по каждому этапу:

1
Этап 1 из 5

Step 1: block.json definition with render.php declaration

~30 минЛегкий

Практическое руководство:

Configure block.json with 'render': 'file:./render.php'. Define attributes: 'postType', 'categoryIds', 'postsPerPage', 'columns', and 'showThumbnails'.

План и контрольные точки реализации:
1Указать apiVersion: 3
2Задать атрибуты postsToShow, columns, selectedCategory с дефолтными значениями
3Привязать render: "file:./render.php"
4Отключить html: false в supports
Важные технические нюансы и подводные камни:

Do not declare a save.js file; dynamic blocks save null or empty content to post_content.

Ожидаемый артефакт этапа:

Валидный конфигурационный файл block.json v3.

JSON
{
  "$schema": "https://schemas.wp.org/trunk/block.json",
  "apiVersion": 3,
  "name": "agenticlab/course-grid",
  "version": "1.0.0",
  "title": "Сетка курсов (Динамическая)",
  "category": "widgets",
  "icon": "grid-view",
  "description": "Автоматический вывод свежих курсов с фильтрацией по рубрикам и кешированием.",
  "supports": {
    "html": false,
    "align": ["wide", "full"],
    "color": { "background": true, "text": true },
    "spacing": { "margin": true, "padding": true }
  },
  "attributes": {
    "postsToShow": { "type": "number", "default": 3 },
    "columns": { "type": "number", "default": 3 },
    "selectedCategory": { "type": "number", "default": 0 }
  },
  "editorScript": "file:./index.js",
  "editorStyle": "file:./index.css",
  "style": "file:./style-index.css",
  "render": "file:./render.php"
}
2
Этап 2 из 5

Step 2: ServerSideRender editor preview component

~45 минСредний
3
Этап 3 из 5

Step 3: Optimized WP_Query & Transients caching in render.php

~40 минСредний
4
Этап 4 из 5

Step 4: Semantic HTML card grid & output escaping

~35 минСредний
5
Этап 5 из 5

Step 5: Cache invalidation hooks & edge-case testing

~20 минЛегкий

Типичные грабли на этом ТЗ

2 антипаттерна

Инструменты экосистемы Fullstack AI Lab для этого ТЗ

Интеграция