Change text "Category Archive" on Category pages to be the Category Title
-
Hi
Anyone know how to change the text at the top of a category page from Category Archive to be the title of the Category itself?
I saw a forum posting elsewhere that said to put this in the archive file which I made one in my child theme folder, archive.php and added the following but it didn’t do anything…clearly I must be doing it wrong or on the wrong track.
Anyone know?
Thanks
Laura
Sorry one more thing,
How do I get rid of the grey space between the bottom of the blue gradient bar containing the title text “Category Archive: Test” and the top of the white page in other words so that the blue title gradient bar would be flush with the white top of the content area?
ModNo, it’s not really the best way, because you’ll miss out on changes to the
category.php
file in the next update (or you’ll have to redo your work). But it works for now, which is the important thing.It might be possible to do this with a filter somehow, but I haven’t looked into it that much yet. You can change some WP text like this (see this post, for example), but I don’t know if it’s possible with the Graphene theme itself.
AdminInsert this into your child theme’s
functions.php
file:function graphene_filter_gettext( $translated, $original, $domain ) {
$strings = array(
'Category Archive: <span>%s</span>' => '<span>%s</span>',
);
if ( ! empty( $strings[$original] ) ) {
$translations = &get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}
return $translated;
}
add_filter( 'gettext', 'graphene_filter_gettext', 10, 3 );Basically every text string in the theme is passed through WordPress first so that the strings can be translated properly into the 20+ languages Graphene theme is available in. The function above just makes use of the WordPress function that translates the strings to change the original text string to a custom one.
ModWell, there you go. Thanks, Syahir.
For those who are interested, this line:
'Category Archive: <span>%s</span>' => '<span>%s</span>',
is what controls that text. For example, I changed it to:
'Category Archive: <span>%s</span>' => 'All my posts from the '<span>%s</span>' category',
which now looks like this:
That’s just full of awesome!
Dangit!! I want Syahir’s knowledge on how he comes up with these functions!!
Thanks, my friend.
Viewing 10 posts - 1 through 10 (of 17 total)
- 1
- 2
- You must be logged in to reply to this topic.