Php 如何在WordPress中使用wp_Title()显示页面标题
我可以试试这个:Php 如何在WordPress中使用wp_Title()显示页面标题,php,wordpress,Php,Wordpress,我可以试试这个: <?php wp_title('|', true, 'right'); ?> 但是在页面标题中显示网页URL。您应该试试这个 <title><?php wp_title('|', true, 'right'); ?></title> 有关更多信息:您可能希望获得当前帖子的标题 <a href="<?php the_permalink(); ?>" rel="bookmark" title="<
<?php wp_title('|', true, 'right'); ?>
但是在页面标题中显示网页URL。您应该试试这个
<title><?php wp_title('|', true, 'right'); ?></title>
有关更多信息:您可能希望获得当前帖子的标题
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
<?php the_title(); ?></a>
参考:
如果您只需要url,可以使用
the_permalink()
函数只需使用the_title()
,此函数仅显示页面标题
或者使用
wp_title(“|”,true,“right”)
,此函数显示为testpage | sitename
此代码将按slug返回页面标题
<?php
global $wp_query;
$post_id = $wp_query->post->ID;
$post = get_post($post_id);
$slug = $post->post_title;
echo $slug;
?>
你也可以参考
请详细说明您的问题!