admin管理员组文章数量:1406937
I have a site where users can claim a business listing. The listings that are not claimed all have the same author. Once they claim them the author becomes the owner of the business. The button sadly does not get removed, that is built in the theme and the theme owner said that will not be added to development.
So I am looking for a code snippet that will inject some CSS onto the pages if the author of the page is not id=2 (that is the author id) This CSS would hide the class of the button which is .claim
There is also a custom field used if that is easier to target for the injection of the field.
Any help or ideas would be greatly apperciated
/
I have a site where users can claim a business listing. The listings that are not claimed all have the same author. Once they claim them the author becomes the owner of the business. The button sadly does not get removed, that is built in the theme and the theme owner said that will not be added to development.
So I am looking for a code snippet that will inject some CSS onto the pages if the author of the page is not id=2 (that is the author id) This CSS would hide the class of the button which is .claim
There is also a custom field used if that is easier to target for the injection of the field.
Any help or ideas would be greatly apperciated
https://rezrising/
Share Improve this question asked Nov 27, 2019 at 11:16 Jason AkeJason Ake 11 Answer
Reset to default 0Welcome to Stack Exchange!
In your theme's function.php, you can add this code:
add_filter('body_class', function($classes) {
$classes[] = 'author-' . get_current_user_id();
return $classes;
});
This will add a CSS class with the current author's ID to <body>
which you can then target:
.author-2 .widget_bt_claim_widget {
display: none;
}
See https://developer.wordpress/reference/functions/get_current_user_id/ for return values.
本文标签: Custom CSS based on the Author of a Post
版权声明:本文标题:Custom CSS based on the Author of a Post 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744962965a2634767.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论