[英]How to Display Page Title Using wp_title() in WordPress
我可以试试这个:
<?php wp_title('|', true, 'right'); ?>
但在页面标题中显示网页URL。
你应该试试这个
<title><?php wp_title('|', true, 'right'); ?></title>
有关更多信息: https : //codex.wordpress.org/Function_Reference/wp_title
此代码将按段返回页面标题
<?php
global $wp_query;
$post_id = $wp_query->post->ID;
$post = get_post($post_id);
$slug = $post->post_title;
echo $slug;
?>
您可能想要获取当前帖子的标题。
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
<?php the_title(); ?></a>
参考: https : //codex.wordpress.org/Function_Reference/get_the_title如果只需要URL,则可以使用the_permalink()
函数
只需使用the_title()
,此函数仅显示页面标题。
或使用wp_title( '|', true, 'right' )
,此功能显示为testpage | sitename
testpage | sitename
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.