WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Display category Title (7 posts)

  1. lukelukeluke
    Member
    Posted 1 year ago #

    Hi, I'm using the shortcode to display categories on my SHOP page. How do I get the category title or name to display under the image?

    Thanks

    Luke

    http://wordpress.org/extend/plugins/woocommerce/

  2. mikejolley
    Member
    Plugin Author

    Posted 1 year ago #

    If you are showing category thumbnails, this should be automatic. Is your theme hiding them?

  3. lukelukeluke
    Member
    Posted 1 year ago #

    I think I edited them out somewhere along the line and couldn't work out how to get them back. I've done it now though with -

    <p><a href="<?php echo get_term_link( $category->slug, 'product_cat' ); ?>"><?php echo  $category->name; ?></a></p>

    Thanks for getting back to me though!

  4. CapitalH
    Member
    Posted 10 months ago #

    if you want to add it to product arcives use this filter:

    function wc_category_title_archive_products(){
    
        $product_cats = wp_get_post_terms( get_the_ID(), 'product_cat' );
    
        if ( $product_cats && ! is_wp_error ( $product_cats ) ){
    
            $single_cat = array_shift( $product_cats ); ?>
    
            <small class="product_category_title"><?php echo $single_cat->name; ?></small>
    
    <?php }
    }
    add_action( 'woocommerce_after_shop_loop_item', 'wc_category_title_archive_products', 5 );

    if you want to add it to a single product title use this:

    function wpa89819_wc_single_product(){
    
        $product_cats = wp_get_post_terms( get_the_ID(), 'product_cat' );
    
        if ( $product_cats && ! is_wp_error ( $product_cats ) ){
    
            $single_cat = array_shift( $product_cats ); ?>
    
            <h2 itemprop="name" class="product_category_title"><span><?php echo $single_cat->name; ?></span></h2>
    
    <?php }
    }
    add_action( 'woocommerce_single_product_summary', 'wpa89819_wc_single_product', 2 );

    thanks to: http://wordpress.stackexchange.com/questions/89819/woocommerce-how-to-display-product-category-above-product

  5. Gabster1501
    Member
    Posted 7 months ago #

    Hello CapitalH,

    can I do the same with brand names? So that under each product in a list/grid view the brand name is under the image?

    And could you tell me where to add this code? Sorry I am new to that!
    THANKS

    Gabster

  6. Gabster1501
    Member
    Posted 7 months ago #

    Ok I figured it out. It is just Product_brand for product_cat. But how could I get the brand name under the image but over the product title. So it is not before and not after the loop but inside.

    Is this possible?

  7. lilrkt
    Member
    Posted 4 months ago #

    @CapitalH for the Product Archives, how can I get the category name to show up above the image?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic