How to display all the category names and images from categories listed from a custom post taxonomy in wordpress? -
i have created custom post type named products , custom taxonomy product categories. have listed number of product category names images in taxonomy product categories. wanted display product category names respective images uploaded(uploaded using category image plugin). images should uploaded <a>
tag. don't know how display category names , images.ihave used types plugin create custom post type , taxonomy , category image plugin load category image. wanted display group of category names , image in below code :
<div class="col-md-4 col-sm-4 col-xs-12"> <a href="pvc_hose.html"> <div class="service wow slideinleft"> <div class="icon"><img src="<?php bloginfo('template_url'); ?>/images/buiding/icon18.png"></div> <h4>pvc hose</h4> </div> </a> </div>
can me on ?
i have attached screenshot of product categories.
if understand correct way, first need create menu in word press admin menu blank menu. go function.php file (theme file) add following code in it.
you can products cateogorty list function,
function get_product_terms( $term_id ) { $html = ''; $args = array( 'hide_empty' => 0, 'parent' => $term_id ); $terms = get_terms('product_cat', $args); foreach ($terms $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; }
you can add products category menu using function,
// filter wp_nav_menu() add additional links , other output function new_nav_menu_items($items) { // woo function /*//product_cat $terms = get_terms( 'product_cat', $args ); print_r($terms);*/ if( $list = get_product_terms( 0 )) { $menu1link = '<li class="home"><a href="' . home_url( '/' ) . '">' . __($list) . '</a></li>'; $homelink = '<li class="home"><a href="' . home_url( '/' ) . '">' . __('home') . '</a></li>'; // add home link end of menu $items = $items . $homelink; $items = $items .$menu1link; } return $items; } add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );
Comments
Post a Comment