Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_image_size('categories_shortcode', 200, 133, true);
- function categories_shortcode_func () {
- $taxonomy = 'product_cat';
- $orderby = 'name';
- $show_count = 0;
- $pad_counts = 0;
- $hierarchical = 1;
- $title = '';
- $empty = 0;
- $archive_view_category = get_queried_object();
- $archive_view_cat_id = $archive_view_category->term_id;
- $athiel_classes = get_body_class();
- $athiel_url_check = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
- $athiel_shop_url = get_site_url().'/shop/';
- if (! in_array('tax-product_cat',$athiel_classes)) {
- $args = array(
- 'taxonomy' => $taxonomy,
- 'parent' => 0,
- 'orderby' => $orderby,
- 'show_count' => $show_count,
- 'pad_counts' => $pad_counts,
- 'hierarchical' => $hierarchical,
- 'title_li' => $title,
- 'hide_empty' => $empty );
- } else {
- $args = array(
- 'taxonomy' => $taxonomy,
- 'child_of' => $archive_view_cat_id,
- 'orderby' => $orderby,
- 'show_count' => $show_count,
- 'pad_counts' => $pad_counts,
- 'hierarchical' => $hierarchical,
- 'title_li' => $title,
- 'hide_empty' => $empty );
- }
- $athiel_cats = get_categories( $args );
- foreach($athiel_cats as $athiel_cat) {
- $id = $athiel_cat->term_id;
- $thumbnail_id = get_woocommerce_term_meta( $id, 'thumbnail_id', true );
- $image = wp_get_attachment_image_src( $thumbnail_id, 'categories_shortcode' );
- $featured = get_field('field_53ea7c23eada3', "{$athiel_cat->taxonomy}_{$athiel_cat->term_id}");
- $title = $athiel_cat->name;
- $link = get_term_link($athiel_cat);
- if($featured == ('yes')) {
- /*$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>
- <a href="' . $link . '" class="postlink"><i class="mukam-link"></i></a>
- <h4 class="post-title">
- <a class="link_title" href="' . $link . '" title="View ' . $title . ' Category">' . $title . '</a>
- </h4></div>';*/
- $a .= '<div class="ATM-list product type-product status-publish has-post-thumbnail Array featuredproduct-item featured">
- <div class="widget-thumb special-thumb">
- <a href="' . $link . '" class="ATM-prod-cats-item"><img width="200" height="133" src="' . $image[0] . '"/></a></div>
- <a href="' . $link . '">
- <h4>' . $title . '</h4>
- </a></div>';
- } }
- return $a;
- }
- add_shortcode('athiel_prod_cats', 'categories_shortcode_func');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement