Unable to Display Page Title Using wp_title() Func

2019-08-12 23:51发布

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>

2条回答
ら.Afraid
2楼-- · 2019-08-13 00:08

you may use

<title>
  <?php
    if ( is_home() ) {
      bloginfo('name');
    } else {
      wp_title('',true,'');
      echo " | ";
      bloginfo('name');
    }
  ?>
</title>
查看更多
贼婆χ
3楼-- · 2019-08-13 00:16

Try this :

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

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

Cheers!

查看更多
登录 后发表回答