- This topic has 7 replies, 2 voices, and was last updated 2 years, 11 months ago by
Tom.
-
AuthorPosts
-
January 9, 2019 at 2:17 pm #777672
Fernando
Hello!
What is the best way to change the categories title, searchs title, not found title and in general all the archive pages titles with GP Premium?
I am thinking in several options, like using a WP or GP filter (generate_archive_title?), or use a header element and hide the .page-header class with CSS… But I’d like to know if there is a better option.
Examples: I don’t what to show Category: name, or Archive: date, Author: name, etc. I want to custom this texts, also in custom posts types like Archive: products… making this Products catalogue, for example.
Suggestion: perhaps you should include it in Elements > Layouts > Disable archive title (also applies to categoriy, search or not found pages).
Thanks!
January 9, 2019 at 5:49 pm #777807Leo
StaffCustomer SupportHi there,
I believe this is what you are looking for:
https://developer.wordpress.org/reference/functions/get_the_archive_title/You can see lots of examples if you search
get_the_archive_title
in our forum.Let me know if this helps 🙂
January 10, 2019 at 12:28 pm #778646Fernando
Hello Leo! I explain…
I have a custom post type called products and want archive pages, but not the default ugly title:
Archives: products
.I was trying to custom this title with a header element, like in blog entries, but it is not possible to hide the default header.page-header without additional css. So a good new option in layout elements would be to hide/disabled this titles (the
header.page-header
container, tell this to Tom :-)).Note that the archive <title> tag is no problem, as can be changed with Yoast Seo.
As a result, I am seeing that the best way to do this is with the filter hook
get_the_archive_title
, isn’t it?As this function:
add_filter( 'get_the_archive_title' ,'rvfa_product_archive_title' ); function rvfa_product_archive_title($title) { if ( is_post_type_archive('rvfa_product') ) $title = 'Catálogo de productos'; return $title; } // :/function
And this result:
January 10, 2019 at 4:43 pm #778774Tom
Lead DeveloperLead DeveloperSo a good new option in layout elements would be to hide/disabled this titles (the header.page-header container, tell this to Tom :-)).
Might be a good idea for the Layout Element. It’s easy to remove with a line of PHP for now though, if you need. If you use
{{post_title}}
in a Hero Element, it will remove the archive title by default.get_the_archive_title
is definitely the way to go for now. It offers the most flexibility. Looks like it’s working nicely for you 🙂January 10, 2019 at 10:20 pm #778861Fernando
Hello Tom,
That was! When insert the
{{post_title}}
tag in a header element, and apply to the archive page, the default archive title dissapears!I was testing other thing: to disable the content title in a layout element, but that doesn’t work in archive pages.
Note that I am new with this plugin. I am a user of the GP free theme since the first versions, but not of GP Premium. Possibilities are (almost) endless, congratulations!
January 11, 2019 at 8:33 am #779316Tom
Lead DeveloperLead DeveloperThat’s right, the content title option won’t work in archives. That’s an interesting idea though – I’ll look into it 🙂
Thanks!
June 25, 2020 at 4:27 am #1341225Rajesh
Hi,
I’ve tried this but somehow it isn’t working…
Here is my function
// ARCHIVE TITLE FILTER
function sy_archive_title( $title ) { if ( is_category() ) { $title = single_cat_title( '', false ) . ' Government Schemes'; } return $title; } add_filter( 'get_the_archive_title', 'sy_archive_title');
June 25, 2020 at 10:09 am #1341766Tom
Lead DeveloperLead DeveloperHi there,
Try giving it a later priority:
function sy_archive_title( $title ) { if ( is_category() ) { $title = single_cat_title( '', false ) . ' Government Schemes'; } return $title; } add_filter( 'get_the_archive_title', 'sy_archive_title', 50);
-
AuthorPosts
- You must be logged in to reply to this topic.