Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registering block templates via plugins in WordPress 6.7 #346

Open
27 tasks
ZaredRogers opened this issue Oct 9, 2024 · 0 comments
Open
27 tasks

Registering block templates via plugins in WordPress 6.7 #346

ZaredRogers opened this issue Oct 9, 2024 · 0 comments
Assignees
Labels
[Feature] Accommodation Accommodation post type related issues and PRs [Feature] Destinations Destinations post type related issues and PRs [Feature] Tours Tours post type related issues and PRs [Status] Needs Dev Ready for, and needs developer efforts [Type] Copy Issues or PRs that need copy editing assistance [Type] Task Issues or PRs that have been broken down into an individual action to take
Milestone

Comments

@ZaredRogers
Copy link

ZaredRogers commented Oct 9, 2024

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.
  • Ensure compatibility with the block editor and the existing LSX Design theme.
  • All templates and patterns should be fully responsive and customizable.
  • Test installation on “fresh” WordPress installs, to ensure the items are loading correctly (no block loading errors).

Tempalte Registration:

  • Custom Templates Registration: Leverage the customTemplates property in the theme.json file to register custom templates. Each template should be defined using an array of template objects with the following properties:
    • name: The name of the template file without the file extension.
    • title: A human-readable title for the template, which can be translated.
    • postTypes: An array of post type slugs that the template is usable on (optional, defaults to page if not specified).
  • Template Structure: For block themes, ensure that each custom template is saved in the theme's /templates folder. For example, a template registered with the name example should correspond to a file named /templates/example.html.
  • Usability Consideration: Be mindful of usability when adding custom templates. Avoid overwhelming users with too many template choices, which could hinder their ability to select the most relevant ones.
  • Template Type Category: Decide on the appropriate template type categories to streamline the template selection process.

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.
@ZaredRogers ZaredRogers added [Type] Task Issues or PRs that have been broken down into an individual action to take [Feature] Tours Tours post type related issues and PRs [Feature] Accommodation Accommodation post type related issues and PRs [Feature] Destinations Destinations post type related issues and PRs [Status] Needs Dev Ready for, and needs developer efforts labels Oct 9, 2024
@ZaredRogers ZaredRogers added this to the 2.0.0 milestone Oct 9, 2024
@ZaredRogers ZaredRogers self-assigned this Oct 9, 2024
@ashleyshaw ashleyshaw added the [Type] Copy Issues or PRs that need copy editing assistance label Oct 10, 2024
@ashleyshaw ashleyshaw changed the title JSON Post Type Registration Registering block templates via plugins in WordPress 6.7 Oct 10, 2024
@ashleyshaw ashleyshaw mentioned this issue Oct 10, 2024
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Accommodation Accommodation post type related issues and PRs [Feature] Destinations Destinations post type related issues and PRs [Feature] Tours Tours post type related issues and PRs [Status] Needs Dev Ready for, and needs developer efforts [Type] Copy Issues or PRs that need copy editing assistance [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
Status: 🏗️ In Progress
Development

No branches or pull requests

3 participants