File: /home/dermova/www/me/wp-content/themes/DERMOVIVA WP THEME AR/category.php
<?php get_header(); ?>
<br class="breakline"/>
</div><!-- header -->
<div id="content">
<div class="mainholder01">
<div class="contentholder txtclrblack bgwhite">
<?php
/* QUERY CUSTOM POST TYPE CATEGORY */
if (is_category( )) {
$cat = get_query_var('cat');
$yourcat = get_category ($cat);
$yourslug = $yourcat->slug;
$yourcatname = $yourcat->name;
echo '<div class="breadcrumb"><a href="http://dermoviva.com/me">Home</a> > Our Products > '.$yourcatname.'</div>';
echo '<div class="contentcol03">
<p> </p><p> </p><h1 class="allcaps">'.$yourcat->name.'</h1><p> </p>';
echo '<p>'.$yourcat->category_description.'</p>';
//$childcats = get_categories('parent=' . $cat . '&hide_empty=1');
$catargs = array(
'parent' => $cat,
'hide_empty' => 1
);
$childcats = get_categories($catargs);
function order_categories($a, $b) {
if ($a->term_id == $b->term_id) {
return 0;
}
return ($a->term_id < $b->term_id) ? -1 : 1;
}
usort($childcats, "order_categories");
if(!empty($childcats)){
echo '<div style="display:inline-block;position:relative;"><p> </p><h1 class="allcaps">'.$yourcatname.' Solutions</h1><p> </p>';
//$childcats = get_categories('parent=' . $cat . '&hide_empty=1');
foreach ($childcats as $childcat) {
if (cat_is_ancestor_of($ancestor, $childcat->cat_ID) == false){
echo '<a href="#'. $childcat->slug.'" class="bttn007 allcaps btn"><span>'. $childcat->cat_name .'</span></a> ';
}
}
echo '</div>';
}
echo '</div>';
echo '<div class="contentcol03">';
// QUERY IMAGE FIELD OF CATEGORY
$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;
$thumbnail = get_field('category_image', $taxonomy . '_' . $term_id);
// QUERY IMAGE FIELD OF CATEGORY
if(!empty($thumbnail)){
echo '<img src="'. $thumbnail .'" class="imgadapt" />';
}
echo '</div><br class="breakline"/>';
}
wp_reset_postdata();
?>
<br class="breakline">
</div><!-- contentholder -->
<?php
/* Our Solutions */
if(!empty($childcats)){
$cntr = 0;
foreach ($childcats as $childcat) {
if (cat_is_ancestor_of($ancestor, $childcat->cat_ID) == false){
echo '<div id="'. $childcat->slug.'" class="contentholder txtcenter txtclrwhite"><div class="pad30"><h1 class="allcaps txtclrwhite">'. $childcat->cat_name . '</h1></div></div>';
echo '<div></div><div class="contentholder txtclrblack bgwhite bgcategory01">';
echo '<div class="productsholder">';
$pageinfo = new WP_Query(array(
'cat'=> $childcat->cat_ID,
'post_type' => 'product',
'post_status' => 'publish'
));
if( $pageinfo->have_posts() ) : while( $pageinfo->have_posts() ) : $pageinfo->the_post();
$postId = get_the_ID();
$featuredimg = get_the_post_thumbnail();
$thetitle = get_the_title();
$thecontent = get_the_content();
$thelink = get_permalink();
echo '<div class="product"><a href="'.$thelink.'">'. $featuredimg.'</a>
<div class="producttitle allcaps">'.$thetitle.'</div>
<a href="'.$thelink.'" class="productlink">View</a>
</div>';
$cntr++;
endwhile; endif;
if($cntr <= 3) {
$addclass = 'only3';
} else {
$addclass = '';
echo '<span class="slider-arrows slider-arrow-left '.$addclass.'">left</span><span class="slider-arrows slider-arrow-right '.$addclass.'">right</span>';
}
echo '</div>';
echo '</div>';
$cntr = 0;
}
}
} else {
echo '<div class="contentholder txtcenter txtclrwhite"><div class="pad30"><h1 class="allcaps txtclrwhite">'. $yourcatname . ' Solutions</h1></div></div>';
echo '<div class="contentholder txtclrblack bgwhite bgcategory01">';
echo '<div class="productsholder">';
$pageinfo = new WP_Query(array(
'post_type' => 'product',
'post_status' => 'publish',
'cat'=> $cat
));
if( $pageinfo->have_posts() ) : while( $pageinfo->have_posts() ) : $pageinfo->the_post();
$postId = get_the_ID();
$featuredimg = get_the_post_thumbnail();
$thetitle = get_the_title();
$thecontent = get_the_content();
$thelink = get_permalink();
echo '<div class="product"><a href="'.$thelink.'">'. $featuredimg.'</a>
<div class="producttitle allcaps">'.$thetitle.'</div>
<a href="'.$thelink.'" class="productlink">View</a>
</div>';
$cntr++;
endwhile; endif;
if($cntr > 3) {
echo '<span class="slider-arrows slider-arrow-left">left</span><span class="slider-arrows slider-arrow-right">right</span>';
}
echo '</div>';
echo '</div>';
}
wp_reset_postdata();
?>
</div><!-- maincontainer -->
</div><!-- content -->
<div id="scrollderhandler">
<div id="pgscroller">
<span class="fa-stack fa-lg">
<i class="fa fa-circle-thin fa-stack-2x fa-5x" aria-hidden="true"></i>
<i class="fa fa-angle-down fa-stack-1x fa-2x" aria-hidden="true"></i>
</span>
</div>
</div>
<script>
dropitstat = 'disable';
</script>
<?php get_footer(); ?>
<!-- CATEGORY -->