Unable to Display Page Title Using wp_title() Function in WordPress

依然范特西╮ 提交于 2019-12-13 00:16:29

问题


Can you please let me know how I can use the wp_title() function to grab each page titles in WordPress. I used the following code to get the title in different page based on titles but it dost' work!

Here is the code I am using

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

回答1:


Try this :

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

Here is the function reference link : http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_title

Cheers!




回答2:


you may use

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


来源:https://stackoverflow.com/questions/19675725/unable-to-display-page-title-using-wp-title-function-in-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!