[Support request] Can’t seem to change Blog title

Home Forums Support [Support request] Can’t seem to change Blog title

Home Forums Support Can’t seem to change Blog title

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1604134
    ClearCity

    I’m helping someone with their website, and they didn’t have a designated Blog page on their site. I’ve assigned a page titled “Musings as the posts page. I’m using the header element (titled Blog Header) and have used this code: <h1>Musings</h1>
    <!–This is a comment.–>. I created a duplicate header (called Site Header) with this code: <h1>{{post_title}}</h1>
    <!–This is a comment.–> and I’ve tried with the location rule for (Blog Header) on Blog page, then Musings page, then Blog and Musings pages, and excluded other pages individually. No matter what I do, the word BLOG shows up over the background images on the Musings/posts page, not the title Musings. I’ve cleared the cache multiple times.

    I’m not sure what I’m missing, or if I need the change the title coding for the word “Blog” in one of the php files, though I don’t know which one (maybe header.php?), nor do I know what to change. I thought <h1>Musings</h1>
    <!–This is a comment.–> would have solved this issue, but I must be missing something. Please assist and thank you.

    #1604141
    Leo
    Staff
    Customer Support

    Hi there,

    Have you tried adding Blog to the Exclusions of the Site Header element?
    https://www.screencast.com/t/D127BhIG

    #1610658
    Peter

    I have the same problem. I would like to display the title of the Posts Page applied in the WP-Admin menu “Pages” instead of “Blog”. In ClearCity’s post above that would be “Musings”, if I understand it correctly.

    The Documentation for {{post_title}} states:

    Will pick up the title of the page or post you’re currently viewing […]

    But for the Posts Page the template tag {{post_title}} always displays “Blog”, no matter what the actual title of the page given in the WP-Admin menu “Pages” is.

    The tag {{post_title}} probably gets the content title defined in the block editor. As the Posts Page cannot be edited in the block editor it does not have that and “Blog” is apparently used as a default. Where does the word “Blog” actually come from?

    Excluding the Site Header from the Posts Page (aka Blog) doesn’t really help in this situation, does it?

    #1611030
    David
    Staff
    Customer Support

    Hi there,

    the {{post_title}} only displays the content title, which WP doesn’t actually generate for the Blog page. So instead GP has a default value of Blog. Generally the best solution is to exclude the Blog from your Header Element and create a separate header element for the blog page where you can manually add your title eg. <h1>Musings</h1>

    Alternatively you can add the following PHP Snippet to get the title for the blog:

    add_filter( 'generate_page_hero_post_title', function( $title ) {
    	if ( is_home() ) {
    		$title = get_the_title(get_option('page_for_posts'));
    	}
    	return $title;
    } );
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.