add_filter( 'body_class', 'replace_author_bob_name' );
function replace_author_bob_name( $classes ) {
// You have all the classes in $classes
// Replaces author-bob with author-hello
$new_classes = array();
foreach($classes as $cls) {
if ($cls == "author-bob") $new_classes[] = "author-hello";
else $new_classes[] = $cls;
}
return $new_classes;
}
1条答案
按热度按时间tcbh2hod1#
你可以通过在functions.php文件中添加一个过滤器来从body_class()函数中删除类。在你的例子中是'author'类。
字符串
您可以在https://developer.wordpress.org/reference/functions/get_body_class/中找到类名引用的完整列表,并从https://developer.wordpress.org/reference/functions/body_class/中查看更多细节。
您也可以查找特定的类名结果并替换它。您有两个:一个是author-name,一个是author-id。
型