Archived topic
How to hide CPT Archive titles?
7 replies · Started by Ema on January 16, 2022
Hello,
I'd like to hide the archive titles on CPT archive pages.
I've tried disabling via elements/layout/disable content title and adding the display conditions
and this code
add_action( 'wp', 'lh_remove_archive_title' );
function lh_remove_archive_title() {
remove_action( 'generate_archive_title', 'generate_archive_title' );
}
I have the titles in the hero section, so don't need to repeat them. But they just won't budge.
Ema
Hi there,
Are you trying to remove this?
https://www.screencast.com/t/vSejqyihuU
If so you would need to add the CPT archives to the Exclusion section of the element.
Let me know if this helps :)
Leo, I managed to do it with the code above after all! It was the hero title in the block, I wanted to keep - then remove the generated archive title which would appear below. Thank you!
No problem :)
Hi. I was trying to do the same thing and the function above worked for me too! thanks for posting. Question? Where did you find or how did you come up with the syntax to write the function if you don’t mind me asking? Is there a generate press codex of sorts?
Sincere thanks in advance for your time.
Hi Brad,
All the codes are in GP's files, if you are familiar with PHP, you should be able to read the codes and find out how to remove/add/modify/filter the original codes :)
The code works - which is great.
the question is, why doesn't Disable Content - "Content Title" work for archives when activated in a page layout?
Hi there,
The Disable Content Title only applies to a post content title, the Archive Titles are a different function. Its something we may address when we next review the Layout Element.