Skip to content

Instantly share code, notes, and snippets.

Created May 16, 2017 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/ab8480231c207caab99df10ad937b163 to your computer and use it in GitHub Desktop.
Save anonymous/ab8480231c207caab99df10ad937b163 to your computer and use it in GitHub Desktop.
function bizplus_portfolio() {
global $bizplus_customizer_all_values;
$bizplus_home_portfolio_title = $bizplus_customizer_all_values['bizplus-home-portfolio-title'];
$bizplus_home_portfolio_sub_title = $bizplus_customizer_all_values['bizplus-home-portfolio-sub-title'];
$bizplus_home_portfolio_number = $bizplus_customizer_all_values['bizplus-home-portfolio-number'];
$repeated_category = array('bizplus-home-portfolio-category-ids');
if( 1 != $bizplus_customizer_all_values['bizplus-home-portfolio-enable'] ){
return null;
}
?>
<section class="wrapper wrap-portfolio wrap-altbg">
<div class="container overhidden">
<div class="row">
<div class="col-md-12">
<header class="title-section evision-animate slideInDown">
<h3><?php echo esc_html( $bizplus_home_portfolio_sub_title );?></h3>
<h2><?php echo esc_html( $bizplus_home_portfolio_title );?></h2>
<span class="title-divider"></span>
</header>
</div>
</div>
</div>
<div class="container overhidden">
<div class="row">
<?php
$bizplus_portfolio_category = evision_customizer_get_repeated_all_value(6 , $repeated_category);
$bizplus_portfolio_cat_posts_ids=array();
foreach( $bizplus_portfolio_category as $bizplus_portfolio_cat_post ) {
if( 0 != $bizplus_portfolio_cat_post['bizplus-home-portfolio-category-ids'] ){
$bizplus_portfolio_cat_posts_ids[] = $bizplus_portfolio_cat_post['bizplus-home-portfolio-category-ids'];
}
}
$bizplus_home_portfolio_args = array();
if( !empty( $bizplus_portfolio_cat_posts_ids) ){
$bizplus_home_portfolio_args = array(
'post_type' => 'post',
'cat' => $bizplus_portfolio_cat_posts_ids,
'ignore_sticky_posts' => true,
);
} ?>
<div id="filters" class="button-group">
<button class="button button-outline is-checked" data-filter="*"><?php echo __( 'show all', 'bizplus' ) ?></button>
<?php for ($j=0; $j < count($bizplus_portfolio_cat_posts_ids) ; $j++) {
$bizplus_category = get_cat_name( $bizplus_portfolio_cat_posts_ids[$j]);
$bizplus_category_id = get_cat_id($bizplus_category);
if (!empty($bizplus_category)) { ?>
<button class="button button-outline" data-filter=".<?php echo esc_html('cat-'.$bizplus_category_id)?>"><?php echo esc_attr( $bizplus_category)?></button>
<?php }
} ?>
</div>
<?php if (!empty ($bizplus_portfolio_cat_posts_ids)){ ?>
<div id='port-gallery' class="grid">
<?php
$bizplus_home_portfolio_post_query = new WP_Query($bizplus_home_portfolio_args);
if ($bizplus_home_portfolio_post_query->have_posts()) :
$data_delay = 0;
while ($bizplus_home_portfolio_post_query->have_posts()) : $bizplus_home_portfolio_post_query->the_post();
$bizplus_cat_id = array();
if(has_post_thumbnail()){
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' );
$url = $thumb['0'];
}
else{
$url = get_template_directory_uri().'/assets/img/no-image.jpg';
}
$data_wow_delay = 'data-wow-delay='.$data_delay.'s';
?>
<?php
$bizplus_categories = get_the_category();
foreach ($bizplus_categories as $bizplus_cat) {
$bizplus_cat_id[] = $bizplus_cat->term_id;
}
$cat_ids = implode(' cat-',$bizplus_cat_id);
?>
<div class="element-item <?php echo ('cat-'.esc_attr($cat_ids)); ?> " data-category="transition">
<div class="radius-thumb-holder">
<figure>
<img src="<?php echo esc_url( $url ); ?>" alt="<?php the_title_attribute();?>">
</figure>
<div class="radius-thumb-hover">
<h3 class="radius-thumb-title">
<a href="<?php the_permalink();?>">
<?php the_title(); ?>
</a>
</h3>
<a class="popup-open" href="<?php echo esc_url( $url ); ?>" alt="<?php the_title_attribute();?>">
<i class="fa fa-arrows-alt" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; wp_reset_postdata();
?>
</div>
<?php } else {
$url = get_template_directory_uri().'/assets/img/no-image.jpg';
?>
<div id='port-gallery' class="grid">
<div class="element-item" data-category="transition">
<div class="radius-thumb-holder">
<figure>
<img src="<?php echo esc_url( $url ); ?>" alt="<?php the_title_attribute();?>">
</figure>
<div class="radius-thumb-hover">
<h3 class="radius-thumb-title">
<a href="#">
<?php echo esc_html__( 'Item title', 'bizplus' ); ?>
</a>
</h3>
<a class="popup-open" href="<?php echo esc_url( $url ); ?>" alt="<?php the_title_attribute();?>">
<i class="fa fa-arrows-alt" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</section>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment