- This topic has 11 replies, 3 voices, and was last updated 4 years, 5 months ago by David.
-
AuthorPosts
-
November 11, 2019 at 1:47 pm #1059919Stefan
Hello,
I’m displaying all of my WooCommerce categories on my hompepage with a WooCommerce shortcode. The category image is displayed with a hyperlink including a product count underneath, like this:
Internet & Marketing (1)
______________________This works fine, but I don’t want the last part of the hyperlink underlined, so it looks like:
Internet & Marketing (1)
___________________In fact, this is the same way a list of my categories are shown via a Widget in a Sidebar.
Any suggestions how I can achieve this?
November 11, 2019 at 3:06 pm #1059964LeoStaffCustomer SupportHi there,
This might be a question for WooCommerce’s support team.
Any chance you can link us to the site in question so I can make sure?
You can edit the original topic and use the private URL field.
Let me know π
November 11, 2019 at 3:30 pm #1059981StefanThank you, I’ve edited the original topic and shared a link to my website.
November 11, 2019 at 4:07 pm #1059999LeoStaffCustomer SupportHmm so by default the titles aren’t underlined.
This CSS you’ve added is adding the underline:
.site-content a, .site-content a:visited, .site-content a:hover { text-decoration: underline !important; }
Unfortunately, I don’t see a way to exclude the product count
<mark>
tag from the CSS above as it’s included in the<a>
tag.November 12, 2019 at 4:04 am #1060285StefanThank you again, What I’m able to do is set the product count to display: none, which works well.
.woocommerce-loop-category__title mark { display: none; }
So it’s kind of strange that text-decoration: none doesn’t remove the hyperlink from the product count.
.woocommerce-loop-category__title mark { text-decoration: none; }
I guess I have to dive deeper into the WooCommerce templates, functions and hooks.
November 12, 2019 at 5:53 am #1060368DavidStaffCustomer SupportHi there,
doesn’t look like there is filter for the category title and as its escaped HTML theres no way to target the text without it effecting the mark tag.
What you could do is this:
.woocommerce-loop-category__title { position: relative; } .woocommerce-loop-category__title .count { position: absolute; }
This moves the element out of the DOM – so it won’t be effected by its parents styling.
November 13, 2019 at 8:39 am #1062094StefanThank you so much, this helps!
After applying your CSS I noticed that the space between the category title and product count had disappeared.
I added some CSS to fix this:
.woocommerce-loop-category__title .count::before { content: '\2005'; }
Then I noticed that the centering of the category title had to be fixed also:
h2.woocommerce-loop-category__title { margin-left: -17px !important; }
Is this the correct way?
Last issue: on a smartphone the Category images (with the titles and product counts underneath) on my homepage are displayed in 2 columns. I’d rather show them on a smartphone in 1 column.
Is there a setting in GeneratePress to do this or should I add some CSS and could you post an example to do this?
November 13, 2019 at 3:08 pm #1062428DavidStaffCustomer SupportThats one way to do it π
You can set the number of columns for Mobile in Customizer > Layout > Woocommerce
November 14, 2019 at 4:36 am #1062835StefanWell, the settings you mention don’t seem to have any effect on my homepage, which is a static page where products and categories are displayed by WooCommerce shortcodes.
So, what I would like to achieve on a smartphone is that products and categories are shown in 1 column.
Right now they are shown in 2 columns.Any further help is much appreciated π
November 14, 2019 at 5:06 am #1062860DavidStaffCustomer SupportAah Woo Shortcodes which can be a bit of a pain.
Try this CSS to force them to 100% wide:@media only screen and (max-width: 768px) { .woocommerce ul.products[class*=columns-] li.product, .woocommerce-page ul.products[class*=columns-] li.product { width: 100%; } }
November 15, 2019 at 3:21 am #1063793StefanThanks again!
I noticed that this had effect on all my other pages with WooCommerce Shortcodes, so I added .page-id-2 (ID of my homepage) so only de homepage will be affected by a 1 column display π
Gladly, my shop page and product pages are unaffected π
@media only screen and (max-width: 768px) { .page-id-2 .woocommerce ul.products[class*=columns-] li.product, .woocommerce-page ul.products[class*=columns-] li.product { width: 100%; } }
Topic resolved π
November 15, 2019 at 8:05 am #1064121DavidStaffCustomer SupportAwesome – thanks for sharing your final code π
-
AuthorPosts
- You must be logged in to reply to this topic.