• Resolved FuzzyToothpaste

    (@fuzzytoothpaste)


    Whenever I go to my WordPress site, it has the site name and description in the title of the browser tab shown twice without a space in between. Instead of showing “Site name | Site description” it shows “Site name | Site descriptionSitename | Site description”. What could cause this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • caused by the filter function on ‘wp_title’ in functions.php of the theme.

    to remove that filter, add this in a child theme of academica, in functions.php:

    add_action( 'after_setup_theme', 'aca_child_setup', 11 );
    function aca_child_setup() {
    	remove_filter( 'wp_title', 'academica_wp_title', 10, 2 );
    }

    then possibly use a seo plugin for the meta titles.

    Thread Starter FuzzyToothpaste

    (@fuzzytoothpaste)

    That worked, thanks. However, I went to my website and looked at the source code, and I didn’t even see any meta titles for search engines. Am I not looking correctly?

    in the html code in the browser, the meta title comes a bit lower as it is added via the ‘wp_head’ action hook.

    in the php code, the meta titles are added via a add_theme_support() code in functions.php;

    // Title Tag
    	add_theme_support( 'title-tag' );

    and then filtered via:

    /**
     * Creates a nicely formatted and more specific title element text
     * for output in head of document, based on current view.
     *
     * @param string $title Default title text for current view.
     * @param string $sep Optional separator.
     * @return string Filtered title.
     */
    function academica_wp_title( $title, $sep ) {
    
    	if ( is_feed() )
    		return $title;
    
    	global $paged, $page;
    
    	// 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 .= " $sep $site_description";
    
    	// Add a page number if necessary.
    	if ( $paged >= 2 || $page >= 2 )
    		$title .= " $sep " . sprintf( __( 'Page %s', 'academica' ), max( $paged, $page ) );
    
    	return $title;
    }
    add_filter( 'wp_title', 'academica_wp_title', 10, 2 );

    this line in the filter function was causing the problem because the dot before the equal sign was appending the original meta title content before the new build one:

    $title .= get_bloginfo( 'name' );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Site title and description shows twics’ is closed to new replies.