我想将当前页面标题放在wordpress中, 但无法获取页面名称, 我试图在我的header.php中使用以下内容
<?php
wp_title(" ");
?>
但是它显示为:”博客名称-当前页面标题”, 当我在我的网站上使用yoast插件时, 就会出现此问题, 如果我停用了该插件, 则当前页面标题会完美显示。
#1
$ page_name = $ wp_query-> post-> post_title;
#2
这会将标题打印到屏幕上。
<?php the_title(); ?>
要进行更多的自定义和升级, 可以使用以下方法:
function the_title( $before = '', $after = '', $echo = true ) {
$title = get_the_title();
if ( strlen( $title ) == 0 ) {
return;
}
$title = $before . $title . $after;
来源:
https://www.srcmini02.com/63332.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_41889.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57