admin管理员组文章数量:1122846
According to this link…
…i can add a filter to change the class(es) of a post. How can I do this from a theme? I just have the functions.php and adding this code there doesnt change anything. currently my single posts look like this:
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<div class="wp-block-group has-light-color-background-color has-background is-layout-constrained wp-container-core-group-is-layout-7 wp-block-group-is-layout-constrained">
(content of a single post)
</div>
</div>
I'd like my child-theme to add a class to one of those divs. But adding the linked filter-code to the functions.php doesnt do anything.
I added this code to the functions.php to no avail:
function rewrite_post_class( $classes, $class, $post_id ) {
$classes[] = 'my-custom-class';
return $classes;
}
add_filter( 'post_class', 'rewrite_post_class', 10, 3 );
本文标签: How can i change the class of a post from a theme
版权声明:本文标题:How can i change the class of a post from a theme? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736299170a1930390.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论