在function.php子主题中添加类名

时间:2015-08-21 13:00:01

标签: php function woocommerce

如何在function.php子主题中添加一个类名。

我正在使用此代码将用户名放在单个产品页面中,我可以看到名称但是没有类名,我必须输入一个类名,以便我可以在css中自定义它。如何在其中添加类名。我希望将classname命名为“userabc”。

function user_name() {
   global $current_user; get_currentuserinfo(); 
   echo $current_user->user_login ;

}

add_action('woocommerce_before_single_product', 'user_name');

1 个答案:

答案 0 :(得分:0)

如果您要修改班级名称,则需要过滤body_classpost_class

function user_name_class( $classes ) {
   $classes[] = get_current_user_id();
   return $classes;

}
add_action('post_class', 'user_name_class');
相关问题