如何在function.php子主题中添加类名。
我使用此代码将用户名放入单个产品页面中,我可以看到名称,但其中没有类名,我必须放入一个类名,以便我可以在css中自定义它。如何在其中添加类名。我想把这个类名命名为"userabc“。
function user_name() {
global $current_user; get_currentuserinfo();
echo $current_user->user_login ;
}
add_action('woocommerce_before_single_product', 'user_name');
发布于 2015-08-21 15:18:19
如果要编辑类名,则需要过滤body_class
或post_class
function user_name_class( $classes ) {
$classes[] = get_current_user_id();
return $classes;
}
add_action('post_class', 'user_name_class');
https://stackoverflow.com/questions/32140978
复制相似问题