Site logo

Archived topic

Custom Page Titles for Post with Taxonomy

8 replies · Started by Thomas on October 11, 2019

Viewing posts 1–9 of 9

I have a group of blog post i like to Append the text "Product Review" to for the H1 Tag.

Current post titles are just product names.

I can technically just disable the page title manually for each page but there are no easy bulk options. Now this creates complexity in maintaining more code.

I would like to tag these post with a tag "review" and if the post has this tag it overrides the default title + adds "Product Review"

Im open for a cleaner way to going about this.

Well that is the idea except this is like adding a "Page Title Banner"

All I Like to do is append additional text to the page title so I don't have to manage any custom design or heading layouts.

What if you created a shortcode?

add_shortcode( 'title_append', function() {
    if ( has_term( 'jazz', 'genre' ) ) {
        return 'Text to append';
    }
} );

Then you can use the [title_append] shortcode.

How would I go about adding it to the title with the shortcode?

<h1>Page Title [title_append]</h1>

Are these regular titles? Or are you using the Elements module?

Regular...

Ah, that's not easy then, unfortunately. WP core does add a filter to the title (called the_title), but that filter applies to everything that has a title (menu items, widget titles, content titles and so on).

The only solution I can think of is to:

1. Disable the regular content title in the theme.
2. Hook in a custom title using Elements.

Let me know if that would work for you and I'll outline the steps :)

This archived topic is closed to new replies.