Skip to content

fix: fallback for empty CPT archive titles - #7582

Open
faisalahammad wants to merge 3 commits into
pods-framework:release/3.4.0from
faisalahammad:fix/7408-the-archive-title
Open

fix: fallback for empty CPT archive titles#7582
faisalahammad wants to merge 3 commits into
pods-framework:release/3.4.0from
faisalahammad:fix/7408-the-archive-title

Conversation

@faisalahammad

Copy link
Copy Markdown
Contributor

Description

Adds a late-priority filter on get_the_archive_title in PodsmInit::core() that falls back to the pod label when upstream filters return empty on Pods post type archive pages.

Reporter on issue #7408 sees the_archive_title() render nothing on Pods CPT archives while the_archive_description() works fine. The trigger is anything that strips the assembled title (most notably Polylang Pro's PLL_MO::translate_if_any(), which returns an empty string when a translation is registered for the post type but no string translation exists for the current language). Pods only ever populates labels->name and labels->archive is left unset, so the empty result reaches the theme.

The new callback runs at priority 20, after WP core (10) and most third-party handlers. It checks the queried post type, looks it up in PodsMeta::$post_types, and substitutes the stored pod label. No behaviour change for non-Pods CPTs, non-empty titles, or sites where translations resolve correctly.

Related GitHub issue(s)

Fixes #7408

Testing instructions

  1. Install the build (build zip uses the standard pods/ plugin directory root; replace the installed Pods plugin).
  2. Create a Pod of type Custom Post Type, e.g. singular Book, plural Books, with Archive enabled.
  3. Add a few published Books.
  4. Install Polylang Pro, set two languages (e.g. EN, IT), mark Books as translatable.
  5. Switch the site to a language where Book label has no string translation in Polylang.
  6. Visit the Books archive page (e.g. /books/).
  7. H1 shows the pod label. Before the fix, the H1 is empty.
  8. Add the string translation under Languages -> String translations, switch language, confirm translation renders. Switch back, fallback kicks in again.
  9. Create a non-Pods CPT and visit its archive; WP default Archives: <label> still applies (filter is a no-op for non-Pods CPTs).

Screenshots / screencast

Pre-fix (Polylang Pro, language without string translation; archive H1 empty):

  • Without fix: no H1 on /books/.
  • With fix: H1 reads Archives: Books (or the pod label as configured).

Changelog text for these changes

Bug: CPT archive title shows as empty when an upstream translation layer returns an empty string for the pod label. The title now falls back to the stored pod label. #7408 (@faisalahammad)

PR checklist

Note on the last checkbox: no existing test infrastructure in this repo exercises PodsmInit filters end-to-end, and adding a SLIC harness for a single filter is out of scope for this fix. Manual test instructions above cover the regression.

Add a late-priority get_the_archive_title filter that falls back to
the pod label when upstream filters return an empty title on Pods
post type archive pages.

Fixes pods-framework#7408
@faisalahammad
faisalahammad changed the base branch from main to release/3.4.0 August 18, 2026 11:23
@faisalahammad

Copy link
Copy Markdown
Contributor Author

AI disclosure: this PR was written with Claude Opus 5 assistance, reviewed and tested by me.

faisalahammad and others added 2 commits August 19, 2026 23:44
The filter runs at priority 20, after core and most third-party filters, so a site
that deliberately blanks archive titles (a theme hooking get_the_archive_title to
return an empty string) would have the title silently re-added on Pods post type
archives with no way to opt out. pods_filter_archive_title gives that escape hatch.

@SInCE was 3.3.10 on a release/3.4.0 base.

Note: the PR description attributes the empty title to labels->archive, but
get_the_archive_title() resolves post type archives through
post_type_archive_title(), which reads labels->name. The fallback is still
worthwhile -- the stated diagnosis is just inaccurate.

Refs pods-framework#7408
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

the_archive_title function does not work

1 participant