开发者

How to change same page/post css styling from page template

开发者 https://www.devze.com 2022-12-30 02:32 出处:网络
How to change same page/post css开发者_Go百科 styling from page template (background, font, etc)Add a custom class to the body tag; you could even use the post name or id for this.

How to change same page/post css开发者_Go百科 styling from page template (background, font, etc)


Add a custom class to the body tag; you could even use the post name or id for this.

Inside the loop of your page.php file you could do the following:

add_filter('body_class','my_body_classes');
function my_body_classes($classes, $class) {
    // add 'post-###' to the $classes array
    $classes[] = 'post-' . the_ID();
    // return the $classes array
    return $classes;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号