[英]Wordpress is_page not working with blog page not home page
我使用静态登录页面作为主页,博客供稿页面是一个单独的页面,称为新闻。 新闻页面的ID为11。我显示的标题如下:
<title><?php bloginfo('name') . ' - ' . the_title();?></title>
但是,当然,在博客页面上,它将加载第一个博客文章标题而不是页面标题。 所以我尝试了这个:
<title><?php bloginfo('name');?> -
<?php if(is_page(11)){?>
News
<?php }else{the_title();}?></title>
但它不起作用,因为某种原因,它认为博客页面也是文章页面-_-
您的第一个代码是可以的。 像这样更改它:
<title><?php bloginfo('name') . ' - ' . wp_title();?></title>
wp_title()根据以下信息检索页面标题: http ://codex.wordpress.org/Function_Reference/wp_title
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.