无法显示网页标题在WordPress使用wp_title()函数(Unable to Display

2019-10-18 21:22发布

可否请您让我知道我可以使用wp_title()函数来抓住每一个页面的标题在WordPress。 我用下面的代码基于冠军拿到冠军在不同的页面,但它多斯特的工作!

这里是我使用的代码

<title>
       <?php 
             if (is_front_page()) {
                          bloginfo('name'); }
             elseif (is_page()) {
                          wp_title(); echo ' - '; bloginfo('name'); }
       ?>
</title>

Answer 1:

尝试这个 :

<?php wp_title('|', true, 'right'); ?>

下面是函数引用链接: http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_title

干杯!



Answer 2:

你可以使用

<title>
  <?php
    if ( is_home() ) {
      bloginfo('name');
    } else {
      wp_title('',true,'');
      echo " | ";
      bloginfo('name');
    }
  ?>
</title>


文章来源: Unable to Display Page Title Using wp_title() Function in WordPress