最近几天, 我一直在编写自己的WordPress主题, 但遇到另一个问题。这些时候, 我不知道如何实现它。
我想为我网站上的每个首页添加一个类。因此, 如果单个页面成为首页, 它将为body标签(例如” home”)提供另一个类。
几乎每个高级主题都具有此功能, 但是我找不到解决方案。
有人知道吗?
谢谢!斯蒂芬
#1
你可以使用body_class过滤器在body标签中添加类, 如下所示:
function home_body_class($classes) {
if ( is_front_page() ) {
$classes[] = 'home';
}
return $classes;
}
add_filter( 'body_class', 'home_body_class' );
你可以操纵静态主页, 博客页面等的条件。
来源:
https://www.srcmini02.com/62753.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_42151.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57