Skip to content

fix(block-theme): ensure newsletter templates are treated as default CPT templates#168

Open
laurelfulford wants to merge 2 commits into
mainfrom
fix/newsletter-default-templates
Open

fix(block-theme): ensure newsletter templates are treated as default CPT templates#168
laurelfulford wants to merge 2 commits into
mainfrom
fix/newsletter-default-templates

Conversation

@laurelfulford
Copy link
Copy Markdown
Contributor

All Submissions:

Changes proposed in this Pull Request:

This PR changes how the single and archive templates for the Newsletter CPT are added to the block theme. The original approach treated them like custom general templates, so they would show up for selection when editing a post or a page.

With this change, the templates should be treated like proper default templates for the CPTs.

How to test the changes in this Pull Request:

  1. On a site running the block theme, edit a post or page and try changing the template. Note that you can see the Single Newsletter and Newsletter Archive templates as options.
  2. Apply this PR.
  3. Retest step one and confirm that those templates are no longer available for selection when editing posts and pages.
  4. Create a new newsletter; confirm that the Single Newsletter template is used as the default.
  5. Navigate to Site Editor, and ensure you can see the Single and Archive Newsletter templates in the available templates to edit.
  6. Try editing both to make them visually distinct (so you can tell they're applied) -- this could just be adding some random text.
  7. Go back to the newsletter editor and create a new newsletter. Try sending it to a test list, and publishing it publicly.
  8. View the newsletter and newsletter archive pages on the front-end of the site. Ensure they're using the right templates by checking for your template edits.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates how the Newspack Block Theme exposes templates for the Newsletter custom post type so they behave like proper CPT hierarchy templates (used automatically for newsletters) instead of appearing as assignable “custom templates” when editing posts/pages.

Changes:

  • Replace the get_block_templates-based title override with a default_template_types filter registration for Newsletter template types.
  • Define human-friendly titles/descriptions for single-newspack_nl_cpt and archive-newspack_nl_cpt as default template types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants