• Hello,

    I have just started with WP and I am finding it impossible to remove the site name from the title of my pages/posts. No matter what I do – my site name always shows after the page name in the title.

    I have the following code in the header.php

    <title><?php wp_title(‘|’, true, ‘right’); ?></title>

    According to what I’ve read, this should display only the name of the page, without adding the name of the site to the title, albeit it’s not working. I have tried modifying the attributes (?) to the wp_title anyway imaginable, but the site name still shows in the title, even when I change it to just wp_title(”).

    Any suggestions on what can I do fix this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • That code does and is designed to do exactly that it does, add | and the title to the right of the current page title.

    The code just before this is what outputs the other part.

    It is also used in SEO, so you may want to keep it.

    Thats said, try:

    <title><?php wp_title("",false); ?></title>

    Also, the list is comma separated.

    Thread Starter atlrus

    (@atlrus)

    Hi Seacoast,

    The code you suggested does not work. When I use it – nothing shows up as a title on any of the pages.

    Again, I am trying to go from YourPage | YourSite to just YourPage in the title.

    Any other suggestions?

    review
    https://codex.www.ads-software.com/Function_Reference/wp_title

    consider to use a seo plugin to have more control.

    Thread Starter atlrus

    (@atlrus)

    @ Alchymyth – I have already read the documentation you linked to, it’s useless, since it offers nothing in a way of removing the site name from the titles. in addition, it’s even more confusing, since it talks about “bloginfo(‘name’)” and I don’t have that in my header.php code, just wp_title().

    I ended up solving the problem by using a SEO plugin, something I was hoping to avoid. The people behind the SEO plugin obviously knew what to do to remove the blog name from the titles, I was hoping someone here would share the secret…

    seo plugins usually use a filter for ‘wp_title’ to overwrite the output with their own.

    it offers nothing in a way of removing the site name from the titles

    the docu is indeed not clear about what exactly will show on a static page or single post;

    you can trace the original core code of wp_title() in /wp-inludes/general-templates.php to find out, and it seems that without particular added filter, it would only show the post or page title.

    if there is also the site name, then this might be due to a filter added by your theme or by a plugin;

    for instance Twenty Twelve uses this filter in functions.php:

    /**
     * Creates a nicely formatted and more specific title element text
     * for output in head of document, based on current view.
     *
     * @since Twenty Twelve 1.0
     *
     * @param string $title Default title text for current view.
     * @param string $sep Optional separator.
     * @return string Filtered title.
     */
    function twentytwelve_wp_title( $title, $sep ) {
    	global $paged, $page;
    
    	if ( is_feed() )
    		return $title;
    
    	// Add the site name.
    	$title .= get_bloginfo( 'name' );
    
    	// Add the site description for the home/front page.
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) )
    		$title = "$title $sep $site_description";
    
    	// Add a page number if necessary.
    	if ( $paged >= 2 || $page >= 2 )
    		$title = "$title $sep " . sprintf( __( 'Page %s', 'twentytwelve' ), max( $paged, $page ) );
    
    	return $title;
    }
    add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );

    what was the theme you had problems with?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Removing site name from title?’ is closed to new replies.