Archived topic
Hide title from category
16 replies · Started by Daniele on October 11, 2022
Hi, how can I hide the SEO title from a category?
Thank you,
Daniele
Hi Daniele,
For reference, can you provide the link to the site in question?
You may use the Private Information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information
I would like to hide the title at the top, the one above the image. In articles it is possible to do this, but this is one category.
Hi there,
are you wanting to remove it just from that Category ? Or ALL categories ?
Hi, only from that category :)
You can use this PHP Snippet to remove the title:
add_action('wp', function(){
if ( is_category( 'your-category-slug' ); ) {
remove_action( 'generate_after_archive_title', 'generate_do_archive_description' );
}
});
You need to update the your-category-slug in the code to match the slug you want it applied to.
If in the future you want to apply it to multiple categories then you can change
if ( is_category( 'your-category-slug' ); ) {
to:
is_category( array( 'your-category-slug', 'another-category-slug', 'and-another-category-slug' ) );
Sorry, I don't understand where you should put it. Can you explain it better?
Thank you.
Hi Daniele,
The code David provided is PHP, you can use one of the methods introduced in below article to add PHP code:
https://docs.generatepress.com/article/adding-php/
Hi, I installed the code snippets plugin and tried adding the code, with my category slug. But it doesn't work, because it tells me that the code contains a syntax error!
This is the code I entered, where I put my category slug:
add_action('wp', function(){
if ( is_category( 'faq-spiritualita-esoterismo-crescita-personale' ); ) {
remove_action( 'generate_after_archive_title', 'generate_do_archive_description' );
}
});
Thanks
Oh I can see the error, try to change it to:
add_action('wp', function(){
if ( is_category( 'faq-spiritualita-esoterismo-crescita-personale' )) {
remove_action( 'generate_after_archive_title', 'generate_do_archive_description' );
}
});
Hi, this is inserted without problems, but I had to remove it because it doesn't do what it is supposed to do, as it deletes the image under the title, and not the title itself!
What I want to delete, is the title text above the image :) Is it possible to do this?
Thanks
Also keep in mind, that that title is inserted by YOST SEO, and I don't want to delete it, but just HIDE it.
Do you mean to hide not remove the title: Domande e Risposte su Dio, Spirito, IO ed Anima?
If so, you can simply use this CSS:
.category-faq-spiritualita-esoterismo-crescita-personale header.page-header {
display: none;
}
I had to remove this too, because in addition to the title, it removes all the page header! Ie also the image and description under the title .. I also tried replacing the word header with title, but it doesn't work :(
Thanks
I see, try this instead:
.category-faq-spiritualita-esoterismo-crescita-personale .page-header h1.page-title {
display: none;
}