wordpress 如何在wordpress中获取页面标题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27653694/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get page title in wordpress
提问by kushalvm
Well, I have tried
<?php echo get_the_title('About Us');?>
嗯,我试过了
<?php echo get_the_title('About Us');?>
But the code is not working. I am using wordpress 4.1. This should work but it isn't. Has wordpress updated the functions?
但是代码不起作用。我正在使用 wordpress 4.1。这应该有效,但事实并非如此。wordpress 更新了功能吗?
回答by Mohammad Al-amin
Try this one, It's may help you
试试这个,它可能会帮助你
<?php single_post_title(); ?>
Thanks :)
谢谢 :)
回答by Rahul Vaghela
Try this one,may it's help you
试试这个,可能对你有帮助
<?php echo get_the_title(); ?>
And if you want to get page or post title By id
如果您想通过 id 获取页面或帖子标题
<?php echo get_the_title(post->$ID); ?>
Thanks
谢谢
回答by Rohil_PHPBeginner
回答by Yamu
<?php
$page = get_page_by_title( 'About Us' );
echo get_the_title($page->ID)
?>

