编辑标题标签Wordpress Tag.php
我正在尝试构建一个输入字段,用于在Wordpress中的tag.php上设置自定义HTML标题标记。我用自定义字段将其归档到page.php上。但是它不知道如何让它在tag.php上工作 在我的职能中,我现在有:编辑标题标签Wordpress Tag.php,wordpress,tags,page-title,Wordpress,Tags,Page Title,我正在尝试构建一个输入字段,用于在Wordpress中的tag.php上设置自定义HTML标题标记。我用自定义字段将其归档到page.php上。但是它不知道如何让它在tag.php上工作 在我的职能中,我现在有: add_theme_support( 'title-tag' ); add_filter( 'document_title_parts', 'orweb_custom_title'); function orweb_custom_title( $title ) { if ( ! is
add_theme_support( 'title-tag' );
add_filter( 'document_title_parts', 'orweb_custom_title');
function orweb_custom_title( $title ) {
if ( ! is_singular() ) return $title;
$custom_title = trim(get_post_meta( get_the_id(), 'title', true ));
if( ! empty( $custom_title ) ){
$custom_title = esc_html( $custom_title );
$title['title'] = $custom_title;
}
return $title;
}
function orweb_custom_title_old($title){
if ( ! is_singular() ) return;
$custom_title = trim(get_post_meta( get_the_id(), 'title', true));
if( ! empty( $custom_title ) ){
$custom_title = esc_html( $custom_title );
$title = $custom_title;
}
return $title;
}
add_filter('wp_title', 'orweb_custom_title_old', 10, 2);
在此处找到: