Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Template part for displaying Our Work Section
*
*@package business_page_plus
*/
?>
<?php
$work_layout = business_page_plus_get_option( 'work_layout' );
$work_title = business_page_plus_get_option( 'work_title' );
$work_category = business_page_plus_get_option( 'work_category' );
$cat = get_the_category_by_ID($work_category);
$cat_link = get_category_link( $work_category );
?>
<?php if('layout-1' == $work_layout):?>
<?php if ( absint( $work_category) > 0 ) { ?>
<div class="custom-container">
<?php if(!empty($work_title)):?>
<header class="entry-header heading">
<h2 class="entry-title"><?php echo esc_html($work_title);?></h2>
</header>
<?php endif;?>
</div>
<div class="portfolio-gallery-section">
<div class="portfolio-gallery-menu">
<ul>
<li class="filter" data-filter="all"><?php echo esc_html__('All','business-page-plus');?></li>
<?php
$args = array(
'type' => 'post',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => FALSE,
'hierarchical' => 1,
'taxonomy' => 'category',
);
if ( absint( $work_category ) > 0 ) {
$args['child_of'] = absint( $work_category );
}
$termchildren = get_categories($args );
foreach($termchildren as $termchildren):
$term_name = $termchildren->name;
$term_slug = $termchildren->slug;
?>
<li class="filter" data-filter=".<?php echo esc_attr($term_slug);?>"><?php echo esc_html($term_name);?></li>
<?php endforeach;?>
</ul>
</div>
<div id="mixit-container" class="portfolio-gallery-demo">
<?php
$category = get_category($work_category);
$term = get_term_children($work_category, 'category');
$child_of = (count($term)) ? 'child_of' : '';
$args = array(
'type' => 'post',
'posts_per_page' => 8,
'child_of' => $category->term_id,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => FALSE,
'hierarchical' => 1,
'taxonomy' => 'category',
);
if(count($term) ){
$termchildren = get_categories($args );
}else{
$termchildren[0] = $category;
}
foreach($termchildren as $termchildren):
$term_name = $termchildren->name;
$term_slug = $termchildren->slug; ?>
<?php $the_query = new WP_Query( array ('category_name'=>$term_slug ) );
while ( $the_query->have_posts()):$the_query->the_post();
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'business-page-plus-work' ); ?>
<div class="single-work mix <?php echo esc_attr($term_slug);?>">
<div class="portfolio-single-gallery">
<?php if(has_post_thumbnail()): ?>
<figure class="protfolio-image">
<a href="<?php the_permalink();?>"> <img src="<?php echo esc_url($featured_image[0]);?>" alt="img"></a>
<div class="work-infomation">
<a href="<?php the_permalink();?>"><i class="fa fa-plus"></i></a>
</div>
</figure>
<?php endif;?>
</div>
</div>
<?php endwhile;?>
<?php wp_reset_postdata(); ?>
<?php endforeach;?>
</div>
<div class="load-portfolio">
<a href="<?php echo esc_url($cat_link);?>" class="load-button"><?php echo esc_html__('View More','business-page-plus');?></a>
</div>
</div>
<?php } ?>
<?php endif;?>
<?php if('layout-2' == $work_layout):?>
<?php if ( absint( $work_category) > 0 ) { ?>
<div class="custom-container">
<header class="entry-header heading">
<h2 class="entry-title"><?php echo esc_html($work_title);?></h2>
</header>
</div>
<div class="portfolio-gallery-section">
<div class="portfolio-gallery-menu">
<ul>
<li class="filter" data-filter="all"><?php echo esc_html__('All','business-page-plus');?></li>
<?php
$args = array(
'type' => 'post',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => FALSE,
'hierarchical' => 1,
'taxonomy' => 'category',
);
if ( absint( $work_category ) > 0 ) {
$args['child_of'] = absint( $work_category );
}
$termchildren = get_categories($args );
foreach($termchildren as $termchildren):
$term_name = $termchildren->name;
$term_slug = $termchildren->slug;
?>
<li class="filter" data-filter=".<?php echo esc_attr($term_slug);?>"><?php echo esc_html($term_name);?></li>
<?php endforeach;?>
</ul>
</div>
<div id="mixit-container" class="portfolio-gallery-demo">
<?php
$category = get_category($work_category);
$term = get_term_children($work_category, 'category');
$child_of = (count($term)) ? 'child_of' : '';
$args = array(
'type' => 'post',
'child_of' => $category->term_id,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => FALSE,
'hierarchical' => 1,
'taxonomy' => 'category',
);
if(count($term) ){
$termchildren = get_categories($args );
}else{
$termchildren[0] = $category;
}
foreach($termchildren as $termchildren):
$term_name = $termchildren->name;
$term_slug = $termchildren->slug; ?>
<?php $the_query = new WP_Query( array ('category_name'=>$term_slug ) );
while ( $the_query->have_posts()):$the_query->the_post();
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>
<div class="single-work mix <?php echo esc_attr($term_slug);?>">
<div class="portfolio-single-gallery">
<?php if(has_post_thumbnail()): ?>
<figure class="protfolio-image">
<a href="<?php the_permalink();?>"> <img src="<?php echo esc_url($featured_image[0]);?>" alt="img"></a>
<div class="work-infomation">
<a href="<?php the_permalink();?>"><i class="fa fa-plus"></i></a>
</div>
</figure>
<?php endif;?>
<div class="portfolio-meta">
<h3 class="portfolio-title"><a href="<?php the_permalink();?>"><?php the_title();?></a></h3>
<?php
$excerpt = business_page_plus_the_excerpt( 10 );
echo wp_kses_post( wpautop( $excerpt ) );
?>
</div>
</div>
</div>
<?php endwhile;?>
<?php wp_reset_postdata(); ?>
<?php endforeach;?>
</div>
</div>
<?php } ?>
<?php endif;?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment