Wordpress标题标签中的Php代码
我已经定制了我的php标题标签,以更改我的网站在主页和单个帖子中的外观。我的代码是:Wordpress标题标签中的Php代码,php,wordpress,title,Php,Wordpress,Title,我已经定制了我的php标题标签,以更改我的网站在主页和单个帖子中的外观。我的代码是: <title><?php is_front_page() ? bloginfo('description') | bloginfo('name') : wp_title(''); ?></title> 在我的主页上,我看不到“|”这个字。如何修复它?试试看 bloginfo('description') .'|'. bloginfo('name') “|”字符表示,或
<title><?php is_front_page() ? bloginfo('description') | bloginfo('name') : wp_title(''); ?></title>
在我的主页上,我看不到“|”这个字。如何修复它?试试看
bloginfo('description') .'|'. bloginfo('name')
“|”字符表示,或者,如果您想将其用作字符,请使用引号。“|”在PHP中表示“逻辑或”
试试看<代码>博客信息('description').|'。bloginfo('name')尝试在function.php中使用它
if ( ! function_exists( '_wp_render_title_tag' ) ) :
function theme_slug_render_title() {
?>
<title><?php wp_title( '|', true, 'right' ); ?></title>
<?php
}
add_action( 'wp_head', 'theme_slug_render_title' );
endif;
如果(!function_存在(''wp_render_title_tag')):
函数主题\u slug\u render\u title(){
?>
据报道,主页有一点漏洞
add_filter( 'wp_title', 'baw_hack_wp_title_for_home' );
function baw_hack_wp_title_for_home( $title )
{
if( empty( $title ) && ( is_home() || is_front_page() ) ) {
return __( 'Home', 'theme_domain' ) . ' | ' . get_bloginfo( 'description' );
}
return $title;
}
和内页
function theme_name_wp_title( $title, $sep ) {
if ( is_feed() ) {
return $title;
}
global $page, $paged;
// Add the blog name
$title .= get_bloginfo( 'name', 'display' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) ) {
$title .= " $sep $site_description";
}
// Add a page number if necessary:
if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
$title .= " $sep " . sprintf( __( 'Page %s', '_s' ), max( $paged, $page ) );
}
return $title;
}
add_filter( 'wp_title', 'theme_name_wp_title', 10, 2 );
我的代码是:
你的代码在哪里?@Rohil_PHPBeginner没有指定代码作为代码,浏览器试图将其解析为html。在这种情况下,它试图解析标题标记。OP第一次写时,没有代码,他在编辑后必须回送它,因为你在索引php标记中,甚至我的博客描述之间没有空格。还有blogname,没有变化。没有帮助,它没有变化。这比发布的其他答案有什么改进?@rnevius,我在还没有提交答案的情况下写了答案!首先,我尝试了这个代码|