Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

remove class :last from li WordPress


Hi I want to remove the :last class from the last li in the woocommerce related products div located on the single product page, e.g here:

what code do I need to add to functions.php to do this? I think the :last class is generated by Wordpress but don't know how to override it. I only want to do it on the related poducts div nowhere else on the site...

Answers (1)


Albert Shala answers:

Try something like this in your css .class-name:nth-child() { display:none; }

willcm comments:

Sorted myself edited theme/woocommerce/content-product.php:

// Extra post classes
if (!is_product()) {
$classes = array();
if ( 0 == ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] || 1 == $woocommerce_loop['columns'] )
$classes[] = 'first';
if ( 0 == $woocommerce_loop['loop'] % $woocommerce_loop['columns'] )
$classes[] = 'last';

Albert Shala comments:

This would do it:

.related-carousel ul li:nth-last-child(1) {
display:none !important;