编辑标题标签Wordpress tag.php

时间:2018-03-01 17:15:27

标签: 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_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);

在此处找到:https://orbitingweb.com/blog/custom-seo-friendly-title-tags-wordpress/

0 个答案:

没有答案