duannuochi3549 2014-04-28 16:00
浏览 74
已采纳

WordPress标题双头标题 - 没有seo插件

Working on a site for a client: http://tinyurl.com/lc4ewwf

I did not create this template, and my client wants me to remover the double titles that is happening to the sub pages. The thing is, I can not figure out what is causing this to happen. This is not happening on the main page either. There is no SEO scripts installed either.

This is what the header.php looks like

<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div id="main">
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<title><?php
    /*
     * Print the <title> tag based on what is being viewed.
     */
    global $page, $paged;

    wp_title( '|', true, 'right' );

    // Add the blog name.
    bloginfo( 'name' );

    // Add the blog description for the home/front page.
    $site_description = get_bloginfo( 'description', 'display' );
    if ( $site_description && ( is_home() || is_front_page() ) )
        echo " | $site_description";

    // Add a page number if necessary:
    if ( $paged >= 2 || $page >= 2 )
        echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );

    ?><?php echo get_the_title($ID); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<?php /*?><link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" /><?php */?>
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php
    /* We add some JavaScript to pages with the comment form
     * to support sites with threaded comments (when in use).
     */
    if ( is_singular() && get_option( 'thread_comments' ) )
        wp_enqueue_script( 'comment-reply' );

    /* Always have wp_head() just before the closing </head>
     * tag of your theme, or you will break many plugins, which
     * generally use this hook to add elements to <head> such
     * as styles, scripts, and meta tags.
     */
    wp_head();
    ?>
    <!-- Styles -->
<link href="<?php bloginfo('template_url'); ?>/css/bootstrap.css" rel="stylesheet">
<link href="<?php bloginfo('template_url'); ?>/css/bootstrap-responsive.css" rel="stylesheet">
<link href="<?php bloginfo('template_url'); ?>/css/styles.css" rel="stylesheet">
<link href="<?php bloginfo('template_url'); ?>/css/wordpress.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

<!-- Favorite Icons -->
<link rel="shortcut icon" href="<?php bloginfo('template_url'); ?>/images/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php bloginfo('template_url'); ?>/images/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="<?php bloginfo('template_url'); ?>/images/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="<?php bloginfo('template_url'); ?>/images/apple-touch-icon-57-precomposed.png">

<!-- TypeKit -->
<script type="text/javascript" src="http://use.typekit.com/zlf3uad.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<!-- For slideshow -->
</head>

<body>

Am I just crazy and is overlooking something?

  • 写回答

2条回答 默认 最新

  • dongxi5423 2014-04-28 16:06
    关注
    wp_title( '|', true, 'right' );
    

    and

    echo get_the_title($ID);
    

    outputs the title; therefore you have two titles.


    Try hooking this up into wp_title function via functions.php:

    function my_wp_title( $title, $sep ) {
        global $paged, $page;
    
        if ( is_feed() ) {
            return $title;
        }
    
        // Add the site name.
        $title .= get_bloginfo( 'name', 'display' );
    
        // 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', 'textdomain' ), max( $paged, $page ) );
        }
    
        return $title;
    }
    add_filter( 'wp_title', 'my_wp_title', 10, 2 );
    

    and use the function in the title:

    <title><?php wp_title(); ?></title>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突