WordPress 加密和私密文章样式修改

本文由清尘发表于2019-09-19 10:44属于WordPress分类

修改主题下的 functions.php,增加一个图标的span标签

//加密码文章前缀修改
add_filter('protected_title_format', 'ips_protected_title_format');
function ips_protected_title_format($prepend){
    return "<span class='protected_ico'></span> %s";
}

//私密文章前缀修改
add_filter('private_title_format', 'ips_private_title_format');
function ips_private_title_format($prepend){
    return "<span class='private_ico'></span> %s";
}

官方hooks链接:https://developer.wordpress.org/reference/hooks/protected_title_format/

效果: