Make WordPress Core

Opened 6 years ago

Last modified 3 months ago

#45955 new enhancement

Twenty Nineteen: get_the_archive_title filter issues

Reported by: taskotr's profile taskotr Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords: has-patch needs-testing
Focuses: Cc:


I was testing the theme with a plugin that adds a custom post type and allows to set a custom title for the custom post type archive view using the following filter:

add_filter( 'get_the_archive_title', 'slug_set_the_archive_title' );

While this filter works fine in the previous WordPress themes, such as Twenty Seventeen, Twenty Sixteen and Twenty Fifteen, it does not work in Twenty Nineteen.

It's possible to fix it by setting a priority parameter in the filter. For example:

add_filter( 'get_the_archive_title', 'slug_set_the_archive_title', 99 );

The problem is that it breaks a header style, meaning the title will have the style of the archive view prefix text (grey color and serif font style).

Any idea what is the better way to use this filter in the
Twenty Nineteen theme?

Attachments (1)

45955.diff (610 bytes) - added by mukesh27 6 years ago.
Patch to change theme filter priority

Download all attachments as: .zip

Change History (4)

#1 @mukesh27
6 years ago

  • Keywords 2nd-opinion needs-patch added
  • Type changed from defect (bug) to enhancement

Hi @taskotr, Welcome to WordPres Trac! Thanks for the report.

Theme already used add_filter( 'get_the_archive_title', 'twentynineteen_get_the_archive_title' ); archive filter with priority of 10 so if you want to override that filter with your plugin functionality then you have to add high priority then 10 then your filter works in Twenty Nineteen.

For ex.

If you have develop plugin with below filter then add below priority.

add_filter( 'get_the_archive_title', 'slug_set_the_archive_title', 99 );

If you have use any third party plugin and it's filter does not work then remove theme filter using below code.

remove_filter( 'get_the_archive_title', 'twentynineteen_get_the_archive_title' );

For better solution, In Twenty Nineteen theme we needs to change filter priority to 1 instead of 10 so plugin can override filter as per there needs.

Last edited 6 years ago by mukesh27 (previous) (diff)

6 years ago

Patch to change theme filter priority

#2 @mukesh27
6 years ago

  • Keywords has-patch added; needs-patch removed

Attached patch change filter priority to 1 instead of 10 so plugin can override filter as per there needs.

#3 @karmatosed
3 months ago

  • Keywords needs-testing added; dev-feedback 2nd-opinion removed
Note: See TracTickets for help on using tickets.