Support » Theme: Cinnamon » Static Home Page

  • Resolved IAmMarchHare

    (@iammarchhare)


    Nice theme, but I have a static front page that simply says “Home”, the title of the page, rather than the site title and tagline. How do I change this?

Viewing 8 replies - 1 through 8 (of 8 total)
  • I’m afraid that it is a new behaviour of WordPress 4.4, not the fault of the theme. I’ve updated to WP 4.4 and the document title of static front page has become “Home – Sitename”, before the update was “Sitename – Tagline”. Note that “Home” is the title of the page set as static front page, you could give it another title.

    Thread Starter IAmMarchHare

    (@iammarchhare)

    Well, I am going to reluctantly mark this as resolved, since it is not a theme issue, but I would have hoped for an answer on how to revert it. Giving it another name only takes care of the title issue, but the tagline will still be missing.

    There are some changes that WP makes at times that baffle me. If they were going to make such a change, it should have been made an option somewhere.

    Hi I know this thread is closed but I’ve also noticed the same problem and have identified some sort of solution, I really appreciate wp’s team on this amazing cms and hope wp don’t blaze me for this but you’ll need to edit the “wp_get_document_title” function located with in wp-includes/general-template.php.

    function wp_get_document_title() {
    
    	/**
    	 * Filter the document title before it is generated.
    	 *
    	 * Passing a non-empty value will short-circuit wp_get_document_title(),
    	 * returning that value instead.
    	 *
    	 * @since 4.4.0
    	 *
    	 * @param string $title The document title. Default empty string.
    	 */
    	$title = apply_filters( 'pre_get_document_title', '' );
    	if ( ! empty( $title ) ) {
    		return $title;
    	}
    
    	global $page, $paged;
    
    	$title = array(
    		'title' => '',
    	);
    
    	// If it's a 404 page, use a "Page not found" title.
    	if ( is_404() ) {
    		$title['title'] = __( 'Page not found' );
    
    	// If it's a search, use a dynamic search results title.
    	} elseif ( is_search() ) {
    		/* translators: %s: search phrase */
    		$title['title'] = sprintf( __( 'Search Results for “%s”' ), get_search_query() );
    
    		// If on the home or front page, use the site title.
    	} elseif ( is_home() ) {
    		$title['title'] = get_bloginfo( 'name', 'display' );
    
    	// If on a post type archive, use the post type archive title.
    	} elseif ( is_post_type_archive() ) {
    		$title['title'] = post_type_archive_title( '', false );
    
    	// If on a taxonomy archive, use the term title.
    	} elseif ( is_tax() ) {
    		$title['title'] = single_term_title( '', false );
    
    	/*
    	 * If we're on the blog page and that page is not the homepage or a single
    	 * page that is designated as the homepage, use the container page's title.
    	 */
    	//} elseif ( ( is_home() && ! is_front_page() ) || ( ! is_home() && is_front_page() ) ) {
    		//$title['title'] = single_post_title( '', false );
    
    	// If on a single post of any post type, use the post title.
    	} elseif ( is_singular() && !is_front_page()) {
    		$title['title'] = single_post_title( '', false );
    
    	// If on a category or tag archive, use the term title.
    	} elseif ( is_category() || is_tag() ) {
    		$title['title'] = single_term_title( '', false );
    
    	// If on an author archive, use the author's display name.
    	} elseif ( is_author() && $author = get_queried_object() ) {
    		$title['title'] = $author->display_name;
    
    	// If it's a date archive, use the date as the title.
    	} elseif ( is_year() ) {
    		$title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) );
    
    	} elseif ( is_month() ) {
    		$title['title'] = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
    
    	} elseif ( is_day() ) {
    		$title['title'] = get_the_date();
    	}
    
    	// Add a page number if necessary.
    	if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
    		$title['page'] = sprintf( __( 'Page %s' ), max( $paged, $page ) );
    	}
    
    	// Append the description or site title to give context.
    	//if ( is_home() && is_front_page() ) {
    	//	$title['tagline'] = get_bloginfo( 'description', 'display' );
    	if ( is_front_page() ) {
    	    $title['site'] = get_bloginfo( 'name', 'display' );
    		$title['tagline'] = get_bloginfo( 'description', 'display' );
    
    	} else {
    		$title['site'] = get_bloginfo( 'name', 'display' );
    	}
    
    	/**
    	 * Filter the separator for the document title.
    	 *
    	 * @since 4.4.0
    	 *
    	 * @param string $sep Document title separator. Default '-'.
    	 */
    	$sep = apply_filters( 'document_title_separator', '-' );
    
    	/**
    	 * Filter the parts of the document title.
    	 *
    	 * @since 4.4.0
    	 *
    	 * @param array $title {
    	 *     The document title parts.
    	 *
    	 *     @type string $title   Title of the viewed page.
    	 *     @type string $page    Optional. Page number if paginated.
    	 *     @type string $tagline Optional. Site description when on home page.
    	 *     @type string $site    Optional. Site title when not on home page.
    	 * }
    	 */
    	$title = apply_filters( 'document_title_parts', $title );
    
    	$title = implode( " $sep ", array_filter( $title ) );
    	$title = wptexturize( $title );
    	$title = convert_chars( $title );
    	$title = esc_html( $title );
    	$title = capital_P_dangit( $title );
    
    	return $title;
    }

    Ajesh_rangoli never recommend to modify core files. It is very bad practice and when you update WordPress you can lose the changes. You should use the acstions and filters that WordPress provides.

    In the case of the document title, since WordPress 4.4 you can use these filters:

    1. pre_get_document_title
    2. document_title_parts
    3. document_title_separator

    To set the title of home static page like “Sitename – tagline” you could use, for example, this code:

    add_filter( 'pre_get_document_title', 'my_document_title_filter' );
        function my_document_title_filter( $title ) {
            if( is_front_page() && ! is_home() ){
                // Add the blog name
    	    $title = get_bloginfo( 'name' );
    	    // Add the blog description for the home/front page.
    	    $site_description = get_bloginfo( 'description', 'display' );
    	    if ( $site_description ) {
                    $title .= "  – " . $site_description;
                }
            }
            return $title;
        }

    Cybmeta, I also don’t like to highlight modifying core files, but for updates to wp 4.5 etc there should be an update to that function. This should be a distinction between a feature or a bug, and should a theme developer use a filter to correct the core?

    You are wrong Aj_rangoli, the filter is not used to fix the core. The filter is used to modify the title generated by the core. I hope you see the difference.

    And yes, if you want to modify what the core generates, you have to use a filter or an action. Always. Never modify core files directly.

    cybmeta I am fully aware of the difference, and I see that you’ve misunderstood the question. Therefore since this thread is resolved in two approaches, one for the great team at wordpress and one for us users, I shall not continuing with this thread.

    I think the opposite, you don’t understand what we are talking about. Even if you understood it and I didn’t, you should never recommend to modify a core file; never. You think carefully before doing such recommendation. Even worst if there is a way to get the desire result without doing it.

    Anyway, having several point of views is always good. Who knows when someone with a different opinion can teach you something.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Static Home Page’ is closed to new replies.