Quantcast
Channel: WordPress.org Forums » [WooCommerce] Support
Viewing all articles
Browse latest Browse all 102102

jayseventwo on "[Plugin: WooCommerce - excelling eCommerce] Display specific categories in list form - working code example provided"

$
0
0

Hi guys, i have the code below which displays all my categories and sub categories in list form, which works perfectly for what i want, but i would like to be able to choose a specific category to choose instead of them all - can this be done? (instead of showing all product_cat, show product_cat = "outdoors" )

if ( is_front_page() ) {

function get_product_terms( $term_id ) {

		$html = '';

		$args = array( 'hide_empty' => 0, 'parent' => $term_id );

		$terms = get_terms('product_cat', $args);

		foreach ($terms as $term) {

			$html .= '<li';

			if( $term_id == 0 ) {

				$html .= ' class="top_li"';

			}

			$html .= '><a href="'.get_term_link($term->slug, 'product_cat').'">' . $term->name . '</a>';	

			if( $list = get_product_terms( $term->term_id )) {

				$html .= '<ul class="second_level">'.$list.'</ul>';

			}

			$html .= '</li>';

		}

		return $html;

	}

	if( $list = get_product_terms( 0 )) {

		echo '<ul id="top_ul">'.$list.'</ul><div style="clear:both;">';

	}

  global $post;

}

Thanks in advance for any help.

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


Viewing all articles
Browse latest Browse all 102102

Trending Articles