• Resolved c4m

    (@c4m)


    Hi,

    I would like to make the category in the single product view non clickable.
    I think i have to change this line:

    <?php echo $product->get_categories( ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', $cat_count, 'woocommerce' ) . ' ', '.</span>' ); ?>

    but I don’t know how.
    Anyone an Idea?

    Best regards,
    Alina

    https://www.ads-software.com/plugins/woocommerce/

Viewing 4 replies - 1 through 4 (of 4 total)
  • The get_categories function calls get_the_term_list, which always produces links. You may just have to produce the category text manually, like so:

    <?php
        $term_names = array_map(
            function($cat) { return $cat->name; },  // just grab the name of each category
            get_the_terms($product->id, 'product_cat')
        );
       echo '<span class="posted_in">' . _n( 'Category:', 'Categories', count($term_names), 'woocommerce') . ' ' . implode(',', $term_names) . '.</span>';
    		?>
    Thread Starter c4m

    (@c4m)

    Thanks so much!

    It’s working ??

    Best regards,
    Alina

    Hi,

    I’m trying to make a non clickable category as well.

    Where should I change this function? I have tried to add it in my functions.php page but it doesn’t work.

    Thank you

    N

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    Nuriaruiz that code is not for functions.php, it’s just in the template wherever the categories were output.

    I suggest using jobs.wordpress.net if you’re stuck.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘make category non clickable’ is closed to new replies.