Skip to content

Instantly share code, notes, and snippets.

@mustafix
Created July 8, 2020 18:43
Show Gist options
  • Save mustafix/ebc2f6c814084158d1c92bbb524b3777 to your computer and use it in GitHub Desktop.
Save mustafix/ebc2f6c814084158d1c92bbb524b3777 to your computer and use it in GitHub Desktop.
// Start ul
<div class="text-center">
<?php
$portfolio_cats = get_terms('portfolio_cat');
if( ! empty($portfolio_cats) && !is_wp_error($portfolio_cats) ) :
?>
<ul class="portfolio-filter">
<li class="active"><a href="#" data-filter="*"> All</a></li>
<?php
foreach($portfolio_cats as $cat){
?><li><a href="#" data-filter=".<?php echo $cat->slug; ?>"><?php echo ucfirst($cat->name); ?></a></li><?php
}
?>
</ul>
<?php endif; ?>
</div>
// End ul
// Start div
<div class="portfolio-grid portfolio-masonry portfolio-gallery grid-3 gutter">
<?php
global $post;
$portfolio_count = get_theme_mod('portfolio_count');
$portfolio_order = get_theme_mod('portfolio_order');
$portfolio_orderby = get_theme_mod('portfolio_orderby');
$post_args = array(
'post_type' =>'portfolio',
'post_status' =>'publish',
'posts_per_page' => $portfolio_count,
'order' => $portfolio_order,
'orderby' => $portfolio_orderby,
);
$portfolio_posts = get_posts($post_args);
foreach( $portfolio_posts as $post ) :
$portfolio_img = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'protfolio' );
$portfolio_cats = get_the_terms(get_the_ID(), 'portfolio_cat');
//var_dump($portfolio_cats);
if( ! empty($portfolio_cats) && !is_wp_error($portfolio_cats) ){
$portfolio_cat_slug = array();
foreach($portfolio_cats as $cat){
$portfolio_cat_slug[] = $cat->slug;
}
$portfolio_cat_array = join( ", ", $portfolio_cat_slug );
$portfolio_cats_array = join( " ", $portfolio_cat_slug );
}
?>
<div class="portfolio-item <?php echo $portfolio_cats_array; ?>">
<a href="<?php echo $portfolio_img[0]; ?>" class="portfolio-image popup-gallery" title="UI Design">
<?php the_post_thumbnail(); ?>
<div class="portfolio-hover-title">
<div class="portfolio-content">
<h6><?php the_title(); ?></h6>
<div class="portfolio-category">
<span><?php echo ucfirst($cat->name); ?></span>
</div>
</div>
</div>
</a>
</div>
<?php endforeach; ?>
</div>
// End div
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment