简体   繁体   English

将课程添加到 <ul> Woocommerce商店和存档页面上的html标签

[英]Add a class to <ul> html tag on Woocommerce shop and archive pages

Somewhere in the html of my Woocommerce shop page I have this line: 在我的Woocommerce商店页面的html中的某处,有以下行:

<ul class="products columns-3">`

I'd simply like to add the bootstrap class "row" to it like: 我只想向其添加引导类“ row”,例如:

<ul class="products columns-3 row"> 

I inserted the bootstrap cdn in my chrome elements tool then added the "row" and I have the result I want it but I can't find in my website files where to change it. 我在Chrome元素工具中插入了bootstrap CDN,然后添加了“行”,我得到了想要的结果,但是在我的网站文件中找不到可以更改的地方。

I know the html code is generated by functions.php , I tried to look down in almost every php page on templates and woocommerce. 我知道html代码是由functions.php生成的,我试图在模板和woocommerce的几乎所有php页面中进行查询。 Can someone explain me how this can be done? 有人可以解释一下该怎么做吗?

To add a custom class to <ul> html tag on WooCommerce shop and archives pages: 要将自定义类添加到WooCommerce商店和存档页面上的<ul> html标签中:

  1. First read "Overriding templates via a theme" official documentation, that explains you how to override woocommerce templates via a theme. 首先阅读“通过主题覆盖模板”官方文档,该文档向您说明如何通过主题覆盖woocommerce模板。

    Note for "Premium Themes": “高级主题”的注意事项
    On some premium themes, they can use already some customized WooCommerce templates, so you will have to use them instead. 在某些高级主题上,他们可以使用一些自定义的WooCommerce模板,因此您将不得不使用它们。 If you are using a child theme with it, copy the related template to your child theme, respecting the same folder hierarchy. 如果要使用子主题,则将相关模板复制到子主题中,并遵循相同的文件夹层次结构。

  2. Once understood this, the related template to edit is loop/loop-start.php . 了解这一点后,要编辑的相关模板就是loop/loop-start.php
    Open/edit it and replace: 打开/编辑它并替换:

     <ul class="products columns-<?php echo esc_attr( wc_get_loop_prop( 'columns' ) ); ?>"> 

    with: 有:

     <ul class="products columns-<?php echo esc_attr( wc_get_loop_prop( 'columns' ) ); ?> row"> 
  3. Save… You are done. 保存...完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM