Issue
There seem to be a lot of questions and answers about how to change post titles and the like, but what I haven’t found is a solution to this:
When you set the homepage of the 2017 theme to "recent posts", this homepage is titled "Posts". After that, all the latest posts with they individual titles are displayed.
The only thing I found was someone mentioning to hide it via CSS.
However, since google doesn’t like hiding elements, and since I actually just want to rename it to something else, this was not a viable solution either.
So how would I go about changing that "Posts" to "Recent Articles" or anything else?
I would probably need to copy a file to a child-theme and edit it?
Solution
page header in twenty seventeen is hard coded as follow:
<?php if ( is_home() && ! is_front_page() ) : ?>
<header class="page-header">
<h1 class="page-title"><?php single_post_title(); ?></h1>
</header>
<?php else : ?>
<header class="page-header">
<h2 class="page-title"><?php _e( 'Posts', 'twentyseventeen' ); ?></h2>
</header>
<?php endif; ?>
so in order to Change that you can do it with gettext
filter as follow:
add_filter( 'gettext', 'change_front_page_title', 20, 3 );
function change_front_page_title( $translated_text, $text, $domain ) {
if (is_front_page()){
switch ( $translated_text ) {
case 'Posts' :
$translated_text = __( 'Recent Articles', 'twentyseventeen' );
break;
}
}
return $translated_text;
}
just place the code in your functions.php
and you are good to go
Answered By – kashalo
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0