Archived topic
Combining two fields as Title
1 reply · Started by siddardha thammana on March 25, 2021
This page is using a H1 title and a H2 subtitle, but in the browser tab and in Google search, they are both showing up together as a Title
https://www.producthunt.com/posts/viable-2
I have a custom post type where there is a title option, which is what shows up on the tab and google
I want to create a new CPT and import the old one to this.
For this new CPT, I want to achieve the same effect where there will be a H1 and H2 on the front end, but they both will be joined as the title. This way I can position the h1 and h2 in different areas but have the benefit of it being the Title
How do I achieve this?
Thanks
Hi there,
you can use the document_title_parts filter:
https://developer.wordpress.org/reference/hooks/document_title_parts/
Heres an example of it being used to change the title on a specific condition:
You simply need to get the Custom Field that you have for your Subtitle, and include that within the title_parts value.