Skip to content

Instantly share code, notes, and snippets.

@hemusyl
Last active August 28, 2016 16:03
Show Gist options
  • Save hemusyl/a42443a2d38f38a95c78fab1c0d7ad54 to your computer and use it in GitHub Desktop.
Save hemusyl/a42443a2d38f38a95c78fab1c0d7ad54 to your computer and use it in GitHub Desktop.
Mixit Up and Isotope Dynamic
http://webdgallery.com/how-to-dynamic-mixitup-or-isotop-in-wordpress/
functions.php
/**
* Adds terms from a custom taxonomy to post_class
*/
add_filter( 'post_class', 'theme_t_wp_taxonomy_post_class', 10, 3 );
function theme_t_wp_taxonomy_post_class( $classes, $class, $ID ) {
$taxonomy = 'filters';
$terms = get_the_terms( (int) $ID, $taxonomy );
if( !empty( $terms ) ) {
foreach( (array) $terms as $order => $term ) {
if( !in_array( $term->slug, $classes ) ) {
$classes[] = $term->slug;
}
}
}
return $classes;
}
--------------------------------
portfolio te bosbe
<section id="portfolio">
<div class="container">
<?php
$one_port_tit = ot_get_option('one_port_tit');
$onepage_port_para = ot_get_option('onepage_port_para');
?>
<div class="section-header">
<h2 class="section-title text-center wow fadeInDown"><?php echo esc_html( $one_port_tit ); ?></h2>
<p class="text-center wow fadeInDown"><?php echo esc_textarea( $onepage_port_para ); ?></p>
</div>
<div class="text-center">
<!-- Filters -->
<?php if(!is_tax()) {
$terms = get_terms("filters");
$count = count($terms);
if ( $count > 0 ){ ?>
<ul class="portfolio-filter">
<li><a class="active"data-filter="*"><?php _e('All Works', 'onepage'); ?></a></li>
<?php
foreach ( $terms as $term ) {
echo '<li><a href="'.get_permalink().'" data-filter=".'.$term->slug.'">'.$term->name.'</a></li>';
} ?>
</ul>
<?php } } ?>
</div>
<div class="portfolio-items">
<?php
global $post;
$args = array( 'post_type'=> 'portfolio', 'posts_per_page' => -1,'pagename=portfolio');
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<?php
$portimage = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'portimage' );
$portlarge = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'portlarge' );
?>
<div <?php post_class ('portfolio-item'); ?>> // 'portfolio-item' class er name
<div class="portfolio-item-inner">
<img class="img-responsive" src="<?php echo $portimage[0];?>" alt="">
<div class="portfolio-info">
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
<a class="preview" href="<?php echo $portlarge[0];?>" rel="prettyPhoto"><i class="fa fa-eye"></i></a>
</div>
</div>
</div><!--/.portfolio-item-->
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
</div>
</div><!--/.container-->
</section><!--/#portfolio-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment