2015-04-22 122 views
1

這裏是頭wp_head()添加第二個標題標籤

<meta charset="<?php bloginfo('charset'); ?>" /> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> 
<title><?php wp_title('|', true, 'right'); ?></title> 
<?php wp_head(); ?> 
.... 

我沒有啓用的插件我的代碼。 有2個過濾器用於wp_head - 沒有用於顯示'標題', 在整個主題代碼中也沒有其他wp_title或'標題'。

有關我如何刪除第二個標題的任何想法?

+1

確保你沒有add_the me_support('title-tag');在函數中.php – yuyokk

+0

第二個標題出現在哪裏?你能顯示生成的HTML嗎? – Jeff

回答

1

從文章中,我最近對WPSE

兩個標題標籤做可以爲你使用的是用於Wordpress4.1寫一個主題,實際上是用4.1來解釋。從4.1你不需要任何更多的調用wp_title()的頭,你可以使用新的title_tag主題支持標籤的自動添加wp_title()標籤在頭

您正在使用的母題是最可能已經這樣做。看在你的functions.php這行代碼

add_theme_support('title-tag'); 

作爲一個解決方案,父主題header.php複製到您的子主題,並簡單地從兒童主題header.php

這裏刪除wp_title()功能也是一偉大的功能要記住的向後兼容性,是父主題開發有用:(從食品兩者)​​

if (! function_exists('_wp_render_title_tag')) { 
    function theme_slug_render_title() 
    { 
     ?> 
     <title> 
      <?php wp_title('|', true, 'right'); ?> 
     </title> 
     <?php 
    } 
    add_action('wp_head', 'theme_slug_render_title'); 
} 
+0

謝謝 - add_theme_support('title-tag');是答案:) – Crerem

+0

我的榮幸,很高興它的工作。請享用 :-) –