Archived topic
Filter hook for {{post_title}}
10 replies · Started by Ash on April 8, 2021
Is there a filter hook for {{post_title}} in the Header Element?
Hi there,
Not sure if I understand.
That is just a template tag that outputs the post title in the header element.
What are you hoping to achieve?
I'd like to modify the output conditionally on a CPT archive/taxonomies.
Then it might be easier to just create a shortcode for your need with something like this:
https://generatepress.com/forums/topic/blog-post-title-customization/#post-1629477
Default page title won't be hidden with the shortcode.
Is there a setting to hide the default page title?
You can use a layout element:
https://docs.generatepress.com/article/layout-element-overview/#disable-element
or this filter:
https://docs.generatepress.com/article/generate_show_title/
Is there an argument of generate_show_title to pass through the default value?
Also somehow Disable Elements on the Layout Element is not working.
Content Title doesn't work on post/cpt archives. Other options such as Top bar works.
Hi there,
you can see the function here:
If its not working on your CPT then it would mean that the your template doesn't include that function.
Neither Layout Element nor generate_show_title works, because it seems that they are not applied for the archive title.
I found that generate_archive_title is needed to modify the archive title.
Just FYI.
add_action('wp',function(){
if(is_post_type_archive('cpt-1')){
remove_action('generate_archive_title','generate_archive_title');
}
},20);
Sorry my bad - i skimmed the topic and only saw the Post - not the archives.... glad yo found the solution