fix: fallback for empty CPT archive titles - #7582
Open
faisalahammad wants to merge 3 commits into
Open
Conversation
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
Contributor
Author
|
AI disclosure: this PR was written with Claude Opus 5 assistance, reviewed and tested by me. |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a late-priority filter on
get_the_archive_titleinPodsmInit::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 whilethe_archive_description()works fine. The trigger is anything that strips the assembled title (most notably Polylang Pro'sPLL_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 populateslabels->nameandlabels->archiveis 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
pods/plugin directory root; replace the installed Pods plugin).Book, pluralBooks, withArchiveenabled./books/).Languages -> String translations, switch language, confirm translation renders. Switch back, fallback kicks in again.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):
/books/.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
PodsmInitfilters 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.