Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. add_image_size('categories_shortcode', 200, 133, true);
  2.  
  3. function categories_shortcode_func () {
  4.  
  5. $taxonomy = 'product_cat';
  6. $orderby = 'name';
  7. $show_count = 0;
  8. $pad_counts = 0;
  9. $hierarchical = 1;
  10. $title = '';
  11. $empty = 0;
  12.  
  13. $archive_view_category = get_queried_object();
  14. $archive_view_cat_id = $archive_view_category->term_id;
  15. $athiel_classes = get_body_class();
  16. $athiel_url_check = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
  17. $athiel_shop_url = get_site_url().'/shop/';
  18.  
  19. if (! in_array('tax-product_cat',$athiel_classes)) {
  20. $args = array(
  21. 'taxonomy' => $taxonomy,
  22. 'parent' => 0,
  23. 'orderby' => $orderby,
  24. 'show_count' => $show_count,
  25. 'pad_counts' => $pad_counts,
  26. 'hierarchical' => $hierarchical,
  27. 'title_li' => $title,
  28. 'hide_empty' => $empty );
  29. } else {
  30. $args = array(
  31. 'taxonomy' => $taxonomy,
  32. 'child_of' => $archive_view_cat_id,
  33. 'orderby' => $orderby,
  34. 'show_count' => $show_count,
  35. 'pad_counts' => $pad_counts,
  36. 'hierarchical' => $hierarchical,
  37. 'title_li' => $title,
  38. 'hide_empty' => $empty );
  39. }
  40.  
  41. $athiel_cats = get_categories( $args );
  42.  
  43. foreach($athiel_cats as $athiel_cat) {
  44.  
  45. $id = $athiel_cat->term_id;
  46.  
  47. $thumbnail_id = get_woocommerce_term_meta( $id, 'thumbnail_id', true );
  48. $image = wp_get_attachment_image_src( $thumbnail_id, 'categories_shortcode' );
  49.  
  50. $featured = get_field('field_53ea7c23eada3', "{$athiel_cat->taxonomy}_{$athiel_cat->term_id}");
  51. $title = $athiel_cat->name;
  52. $link = get_term_link($athiel_cat);
  53.  
  54. if($featured == ('yes')) {
  55. /*$a .= ' <div class="ATM-list"><a class="ATM-prod-cats-item"><img width="200" height="300" src="' . $image[0] . '" class="attachment-medium" alt="shop" /></a>
  56. <a href="' . $link . '" class="postlink"><i class="mukam-link"></i></a>
  57. <h4 class="post-title">
  58. <a class="link_title" href="' . $link . '" title="View ' . $title . ' Category">' . $title . '</a>
  59. </h4></div>';*/
  60. $a .= '<div class="ATM-list product type-product status-publish has-post-thumbnail Array featuredproduct-item featured">
  61. <div class="widget-thumb special-thumb">
  62. <a href="' . $link . '" class="ATM-prod-cats-item"><img width="200" height="133" src="' . $image[0] . '"/></a></div>
  63.  
  64. <a href="' . $link . '">
  65.  
  66.  
  67. <h4>' . $title . '</h4>
  68.  
  69. </a></div>';
  70.  
  71. } }
  72.  
  73. return $a;
  74. }
  75. add_shortcode('athiel_prod_cats', 'categories_shortcode_func');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement