[英]How to get current page name in wordpress
I want to put the Current page title in wordpress but unable to get the page name, i have tried to use following into my header.php我想将当前页面标题放在 wordpress 中,但无法获取页面名称,我尝试在 header.php 中使用以下内容
<?php
wp_title(" ");
?>
But it is displaying as: "Blog Name - Current Page title "
this problem is coming when i using yoast plugin in my website, if i am deactivating the plugin then current page title is displaying perfectly.但它显示为:
"Blog Name - Current Page title "
当我在我的网站上使用 yoast 插件时会出现这个问题,如果我停用插件,则当前页面标题显示完美。
This would print the title to the screen.这会将标题打印到屏幕上。
<?php the_title(); ?>
For more customized and advancement you can use below:如需更多定制和进步,您可以使用以下内容:
function the_title( $before = '', $after = '', $echo = true ) {
$title = get_the_title();
if ( strlen( $title ) == 0 ) {
return;
}
$title = $before . $title . $after;
$page_name = $wp_query->post->post_title;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.