Lisa A.
Lisa A.

Reputation: 1

woocommerce empty product name field

I'm using WooCommerce 2.3.8 and WordPress 4.2.1. Is there a way to remove the product title from an individual product? I used to be able to just put a blank space and the product title would be blank, but now it doesn't let me, it just keeps putting the original product title back in when I update the product. This is only for one category of products. I would like to have a category page of products that have no titles, just the featured images in a grid.

Thank you!

Upvotes: 0

Views: 893

Answers (1)

Robin Vinzenz
Robin Vinzenz

Reputation: 1277

1. Dirty Solution

Use CSS: All of your list items for a product on a category have css classes named after the categories' name e.g. product_cat-mycatgegory. You can find the product's title within an <h3> element.

Therefore the following CSS Code would prevent displaying the product's title on the category page.

.product_cat-mycatgegory h3{
    display:none;
}

Note that the product title is be still readable via the browser's inspector.

2. Cleaner Solution

You could edit the content-product.php template. Check if a current category is chosen and decide whether to show the title or not. Please check woocommerce's documentation about template structure and overriding.

Pseudocode

<?php

$cat_obj = $wp_query->get_queried_object();
$category_ID  = $cat_obj->term_id;

if(!($category_ID == category_ID_without_titles)) :?>
    <h3><?php the_title(); ?></h3>
<?php endif;?>

Upvotes: 1

Related Questions