【问题标题】:wp_title is blank on all pages in wordpress sitewp_title 在 wordpress 网站的所有页面上都是空白的
【发布时间】:2016-05-31 08:31:13
【问题描述】:

我对 wordpress 比较陌生。我有一个问题,wp_title 在我网站的所有页面上都显示为空白。

我看到一些帖子解决了页面标题未显示在索引页面上,但没有发现任何相关内容未显示在网站的所有页面上。

使用下面的代码,我的标题标签使用站点名称呈现,但没有页面名称:

<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";
</title>

就像我说的那样,我是使用 Wordpress 的新手,所以我很有可能在这里遗漏了一些非常明显的东西......

【问题讨论】:

  • 日志中有什么有趣的事情吗?
  • 我刚刚检查过 - 什么都没有,@Lee
  • 最终通过安装 Yoast SEO 插件为我自己解决了这个问题,事后看来这对我的情况来说更好。没有解释为什么 wp_title 没有显示,但至少它现在可以工作

标签: php wordpress title


【解决方案1】:

你为什么不使用? printf (get_bloginfo('url')), printf (get_bloginfo('description'), printf ('sitename')。

【讨论】:

  • 这不会返回页面名称,例如。 “关于”、“联系方式”、“博客”等。
猜你喜欢
  • 2012-02-21
  • 1970-01-01
  • 2022-11-02
  • 2019-11-12
  • 2015-06-28
  • 1970-01-01
  • 1970-01-01
  • 2022-10-23
  • 2013-08-22
相关资源
最近更新 更多