- This topic has 18 replies, 2 voices, and was last updated 1 year, 10 months ago by Leo.
-
AuthorPosts
-
November 9, 2018 at 8:06 am #723105Raphael
Hi,
I want to remove the page-title on category-archive pages because I want to hook an individual archive-title/logo-template created with Elementor. „display:none“ is not an option because of SEO.
Deactivating the title with Elements-layout doesn´t work.
Here I found this solution: https://docs.generatepress.com/article/generate_show_title/ and customized it like this:add_action( 'after_setup_theme', 'remove_category_titles' ); function remove_category_titles() { if ( is_category( '' ) ) add_filter( 'generate_show_title', '__return_false' ); }
But it doesn´t work. How it is possible to remove the archive-title?
Thanks!
November 9, 2018 at 2:15 pm #723319DavidStaffCustomer SupportHi there,
try the
is_archive()
theis_category( 'slug' )
is used for posts of set category.November 14, 2018 at 2:06 pm #727507RaphaelHi David,
thanks for your quick reply. In the meantime I found a solution.
The filter
generate_show_title
unfortunately works only on pages and posts. It´s not working on archives.With this function it´s possible to remove the titles on all archive pages:
add_action( 'after_setup_theme', 'remove_archive_titles' ); function remove_archive_titles() { add_filter( 'get_the_archive_title', function ($title) { return ''; } ); }
See here.
But an empty
<h1 class="page-title"></h1>
still remains there.Another question:
It´s possible to customize
archives.php
(inc -> structure) by uploading the file to the child-theme-directory? I tested it but nothing was changing.November 14, 2018 at 6:23 pm #727645TomLead DeveloperLead DeveloperTry this instead:
remove_action( 'generate_archive_title', 'generate_archive_title' );
It’s not possible to overwrite that file, as it’s not a regular template file. What changes are you wanting to make?
February 10, 2019 at 4:22 am #806491AMBTLHi guys,
I have the same issue as Raphael.
Usually, I use {{post_title}} in page headers and then there is no issue.
But sometimes post_title in its exact form is not desired.Then the white box with archive title appears.
doing this:
add_filter( 'get_the_archive_title', function ($title) { return ''; });
removes the text, but an empty header remains in the source and creates a white box:
<header class="page-header"> <h1 class="page-title"> </h1> </header>
——————–
Adding thisremove_action( 'generate_archive_title', 'generate_archive_title' );
doesn’t seem to do anything at all.
Any other ideas? (besides doing display:none)
Cheers
TomFebruary 10, 2019 at 4:43 am #806504AMBTLOh, nevermind guys; I have found the solution:
add_action( 'after_setup_theme', function() { remove_action( 'generate_archive_title', 'generate_archive_title' ); } );
Cheers
TomFebruary 10, 2019 at 8:43 am #806716TomLead DeveloperLead DeveloperGlad you got it working – thanks for sharing the code 🙂
February 15, 2019 at 2:17 pm #811585RaphaelUnfortunately this code is not working for me. With Elementor I build a page-template with page-header and content, because I want an individual header.
The action removes also the title generated by Elementor. Without the code both titles are visible. So I need the page-title, but only generated by the Elementor-template.
Any idea how to achieve this?
Thanks!
RaphaelFebruary 15, 2019 at 5:12 pm #811669TomLead DeveloperLead DeveloperAny chance you can link us to the page where both titles are showing?
Let me know 🙂
February 16, 2019 at 6:49 am #812049RaphaelHi Tom,
sorry, yes, of course 🙂
https://barbarabaum.de/artikel/
or
https://barbarabaum.de/baumblueten/
Currently there is only one title visible.
The second is hidden by the function above, so there still remains:
<h1 class="page-title"></h1>
Thanks,
Raphael
February 16, 2019 at 10:05 am #812218TomLead DeveloperLead DeveloperHow are you currently getting the Elementor element into the archive title area?
April 10, 2020 at 1:45 am #1233607ElenaHi guys,
I have the same problem. I need to remove the default <h1> from category pages.
I saw that this could do the magic:
add_action( ‘after_setup_theme’, function() {
remove_action( ‘generate_archive_title’, ‘generate_archive_title’ );
} );My question is…on which file should I add that snippet? And where inside the file?
Sorry I have no PHP knowledge 🙂
Thanks in advance
April 10, 2020 at 7:33 am #1233882DavidStaffCustomer SupportHi there,
this article explains more:
https://docs.generatepress.com/article/adding-php/TLDR: In Child Theme > functions.php file or use the Code Snippets plugin
April 10, 2020 at 8:53 am #1234136ElenaWorked perfectly with the plugin 🙂
Thank you!
April 10, 2020 at 10:13 am #1234259DavidStaffCustomer SupportGlad we could be of help
-
AuthorPosts
- The topic ‘Remove the title on category-archive pages’ is closed to new replies.