- This topic has 11 replies, 1 voice, and was last updated 2 years, 4 months ago by
Angelo.
-
AuthorPosts
-
June 1, 2019 at 7:09 am #917147
Riley
We are using both GP and the GP Premium Plugin on a brand new site we are building. When we try to change the Posts Page to a new page (or even rename the default blog page) the slug in the URL can change, but the title itself which appears in the header on the page does not change. It remains ‘blog’. (Except in one situation where: we renamed the blog page to lessons, the title remained ‘blog’, then we renamed it to Lessons1, still ‘blog’, created another page called ‘lessons’, pointed the Posts Page to ‘lessons’, then the title said ‘lessons1’, when it should have said ‘lessons’.)
June 1, 2019 at 7:10 am #917149Riley
Also (I can create another ticket for this, but it seems related), we disabled the footer on this page, but the footer still appears.
June 1, 2019 at 8:21 am #917186Tom
Lead DeveloperLead DeveloperHi there,
Are you using a Header Element? If so, try this PHP:
add_filter( 'generate_page_hero_post_title', function( $title ) { if ( is_home() ) { $title = 'Your new title'; } return $title; } );
How did you disable the footer? I’m not able to see your site (it’s coming soon).
June 1, 2019 at 10:46 am #917248Riley
I believe we are using the default Global Header. But we shouldn’t have to use PHP code, the default ‘blog’ page should automatically show the same title as the title of the page, correct? I mean, this is the case for every other single page. (The difference between all other pages and the one we are having issues with is that we are assigning this page as the ‘Posts Page’ in the Customizer.)
And for the footer, I need to make a correction. In the page editor, in the Layout section, we are settings widgets to 0, yet the three default widgets still appear.
We are using the ‘Catalyst’ site layout from your Site Library.
I’ll disable the cover for now, but will throw it back up in a couple hours. (The page which we are having issues on is the Videos page.)
June 1, 2019 at 4:26 pm #917345Tom
Lead DeveloperLead DeveloperIf the page is the posts page, it will default to “Blog”. This is because WordPress disconnects itself from the actual page if it’s set as the posts page. The function I shared should work.
So while editing the page content, you’ve used the “Layout” metabox to set the widgets to 0? This is the same issue as above, WordPress doesn’t listen to the page settings when it’s set as the posts page. You’ll need to set the widgets to 0 in the Customizer (Customize > Layout > Footer).
June 1, 2019 at 5:17 pm #917362Riley
Those work, thank you!
June 2, 2019 at 7:08 am #917773Tom
Lead DeveloperLead DeveloperYou’re welcome ๐
August 17, 2019 at 12:29 pm #986762William
Sorry, I have encountered the same problem. Exactly where should this php be inserted?
Thanks
August 17, 2019 at 1:22 pm #986782Leo
StaffCustomer SupportAdding PHP: https://docs.generatepress.com/article/adding-php/
Code Snippets is the easiest method if you aren’t using a child theme already.
August 17, 2019 at 5:35 pm #986868William
Thanks, worked! Sorry again for the basic question, I’m new to using the child themes.
August 17, 2019 at 7:53 pm #986916Leo
StaffCustomer SupportNo problem ๐
January 24, 2021 at 4:48 pm #1631944Angelo
Tom, hardcoding the word “Blog” into GP Premium is very unintuitive. It took me 30+ mins of Googling and searching the source code to find your solution.
You should to add your snippet to these doc pages:
https://docs.generatepress.com/article/header-element-overview/
https://docs.generatepress.com/article/header-element-template-tags/I think it makes more sense to use the name of the static page as a fallback instead of the word “Blog”. I modified your function to grab the static page name:
add_filter( 'generate_page_hero_post_title', 'cc_page_hero_title' ); function cc_page_hero_title($original_title) { if(is_home()){ $static_page_id = get_option('page_for_posts', true); if($static_page_id){ return get_the_title($static_page_id); } } else { return $original_title; } }
-
AuthorPosts
- You must be logged in to reply to this topic.