[Support request] Product categories on homepage and shop

Home Forums Support [Support request] Product categories on homepage and shop

Home Forums Support Product categories on homepage and shop

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1111375
    Pedro

    Hello! I would like to show the product categories on the homepage and shop.

    As shown on the shop page in the niche template.

    #1111813
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Niche is using a Hook Element with this content:

    <?php
    $cat_args = array(
    	'orderby'    => 'name',
    	'order'      => 'asc',
    	'hide_empty' => true,
    );
     
    $product_categories = get_terms( 'product_cat', $cat_args );
     
    if ( ! empty( $product_categories ) ) {
    	echo '<ul class="woo-cat-nav">';
    		foreach ( $product_categories as $key => $category ) {
    			printf( 
    				'<li>
    					<a href="%1$s">
    						%2$s
    					</a>
    				</li>',
    				get_term_link( $category ),
    				$category->name
    			);
    		}
    	echo '</ul>';
    }
    ?>

    The hook is set to “woocommerce_archive_description” and “Execute PHP” is checked.

    These are the Display Rules: https://www.screencast.com/t/ENlaz82e

    Hope this helps 🙂

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.