Skip to content

Registering block templates #346

@ZaredRogers

Description

@ZaredRogers

Description

We need to register three custom post types in the Tour Operator plugin: Tours, Accommodation, and Destinations. These post types will manage content related to the tours offered, accommodations available, and destinations covered within the plugin.

Requirements

  • All templates should be registered using the register_block_template() function, ensuring compatibility with the block editor.
  • Templates should follow WordPress standards and include placeholders for dynamic content (e.g., title, content, featured image).
  • Patterns should be registered using register_block_pattern() with appropriate categories (e.g., tours, accommodation, destinations).
  • Patterns should feature pre-defined blocks to create structured layouts for tour, accommodation, and destination information.
  • Template should be grouped by the author (the plugin name)

Templates to Register:

Single Templates:

  • single-tour
  • single-accommodation
  • single-country
  • single-region

Archive Templates:

  • tour-archive
  • accommodation-archive
  • destination-archive

Term Archives

  • Continent - Term Archive
  • Travel Style - Term Archive
  • Type - Term Archive
  • Brand - Term Archive

Search Results

  • Archive - No search Filters
  • Archive - With Search filters

References:

  • [Tutorial on Registering block templates via plugins in WordPress 6.7] (https://developer.wordpress.org/news/2024/08/29/registering-block-templates-via-plugins-in-wordpress-6-7/)
  • Add plugin template registration API #61577
  • Adding custom templates
  • You can register custom templates via the customTemplates property in theme.json. It accepts an array of template objects, each defining an individual template.
  • Each object passed to the customTemplates array supports these properties:
    • name: The name of your template file without the file extension.
    • title: A human-readable title for your template, which may be translated.
    • postTypes: An array of post type slugs that the template is usable on. This is an optional setting and defaults to the page post type.
  • For block themes, WordPress will look for custom templates (all templates, actually) in the theme’s /templates folder. Therefore, if you register a template with the name of example, you must also have an /templates/example.html file in your theme.
  • You can add as many custom templates as you want to your theme. Just keep in mind the usability aspect of offering too many choices.

Metadata

Metadata

Labels

area:contentAnything that needs copy-editing assistancestatus:in-progressWork actively underwaystatus:needs-devEarly execution signal (triage queue for engineering)

Type

Projects

Status

🏗️ In Progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions