【问题标题】:Element Title appears 2 times in my wordpress website元素标题在我的 wordpress 网站中出现 2 次
【发布时间】:2015-05-22 15:05:38
【问题描述】:

我有一个 WP 网站,并使用 yoast seo。

现在,在我的 html 级别的网站中。我的代码如下所示 <title>my website</title><title>my website</title>

标题中相同标题部分的 2 次。现在怎么解决呢? header.php 的任何问题。谢谢

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" <?php
language_attributes();
?>>

<head>

<meta http-equiv="Content-Type" content="<?php
bloginfo('html_type');
?>; 

charset=<?php
bloginfo('charset');
?>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>

  <?php
if (function_exists('is_tag') && is_tag()) {

    single_tag_title('Tag Archive for &quot;');
    echo '&quot; - ';

} elseif (is_archive()) {

    wp_title('');
    echo ' Archive - ';

} elseif (is_search()) {

    echo 'Search for &quot;' . wp_specialchars($s) . '&quot; - ';

} elseif (!(is_404()) && (is_single()) || (is_page())) {

    wp_title('');
    echo ' - ';

} elseif (is_404()) {

    echo 'Not Found - ';

}
if (is_home()) {

    bloginfo('name');
    echo ' - ';
    bloginfo('description');

} else {

    bloginfo('name');

}
if ($paged > 1) {

    echo ' - page ' . $paged;

}
?>

</title>

【问题讨论】:

  • 请将代码发布到 header.php。
  • 没有更多的代码,我们无能为力
  • 我已经添加了代码。请再次检查,谢谢

标签: php wordpress


【解决方案1】:

header.php 文件应如下所示。通过传入 name 参数确保参数设置正确&lt;?php bloginfo( 'name' ); ?&gt;,并检查以确保代码没有在任何地方重复。

<!doctype html>

<head>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Likely problem area -->
    <title>
        <?php wp_title( '|', true, 'right' ); ?>
        <?php bloginfo( 'name' ); ?>
    </title>

    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">

    <?php wp_head(); ?>

</head>

【讨论】:

  • 我已经在header.php中添加了实际的标题部分,请您检查并纠正它吗?
  • 发布所有 header.php 〜我不相信这段代码违反了什么
  • 就是这样。一些JS放在header.php的中。你能再检查一下 部分吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-27
  • 1970-01-01
  • 2022-01-02
  • 2021-12-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多