Created
June 8, 2017 10:23
-
-
Save dn7734/9b99dee61cc552a7cffc088ea1f3f154 to your computer and use it in GitHub Desktop.
wp archive for portfolio cpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
do_action('get_header'); | |
get_template_part('templates/header'); | |
?> | |
<?php get_template_part('templates/base'); ?> | |
<div class="content"> | |
<?php //начало выборки терминов для таксономии portfolio_cat | |
$terms = get_terms( 'portfolio_cat', array( | |
'orderby' => 'date', | |
'order' => 'DESC', | |
'hide_empty' => 0 | |
) ); | |
?> | |
<!-- ============================== Gallery ===========================--> | |
<hr class="tall"> | |
<section class="gallery gallery_two container"> | |
<div class="gallery_menu_wrapper"> | |
<ul class="gallery_menu"> | |
<li class="filter active transition3s" data-filter="all">Показати все</li> | |
<?php | |
// теперь выполняется запрос для каждого | |
$icout = 1; | |
$numItems = count($terms); | |
foreach( $terms as $term ) { | |
$icout++; | |
// Определение запроса | |
$args = array( | |
'post_type' => 'portfolio', | |
'portfolio_cat' => $term->slug | |
); | |
$posts_query = new WP_Query( $args ); | |
// вывод названий записей в тегах заголовков ?> | |
<?php if( $posts_query->have_posts() ) : ?> | |
<li class="filter transition3s" data-filter=".<?php echo $term->slug; ?>"><?php echo $term->name; ?></li> | |
<?php endif; | |
// используем сброс данных записи, чтобы восстановить оригинальный запрос | |
wp_reset_postdata(); | |
} ?> | |
</ul> | |
</div> <!-- End .menu_wrapper --> | |
<div class="gallery_item_wrapper" id="mixitup_list"> | |
<?php | |
// теперь выполняется запрос для каждого | |
foreach( $terms as $term ) { | |
// Определение запроса | |
$args = array( | |
'post_type' => 'portfolio', | |
'portfolio_cat' => $term->slug | |
); | |
$posts_query = new WP_Query( $args ); | |
// вывод названий записей в тегах заголовков ?> | |
<?php if( $posts_query->have_posts() ) : ?> | |
<?php while( $posts_query->have_posts() ) : $posts_query->the_post(); ?> | |
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 mix <?php echo $term->slug; ?>"> | |
<div class="single_item"> | |
<div class="img_holder"> | |
<a href="<?php the_post_thumbnail_url( 'full' ); ?>" class="fancybox"><?php the_post_thumbnail( 'post-thumb', array( 'class' => 'img-responsive' ) ); ?></a> | |
<div class="title tran3s"> | |
<a href="<?php the_permalink(); ?>"> | |
<h5><?php the_title(); ?></h5> | |
<span><?php echo $term->name; ?><i class="fa fa-angle-right" aria-hidden="true"></i></span> | |
</a> | |
</div> <!-- End of .title --> | |
</div> <!-- End of .img_holder --> | |
</div> <!-- End of .single_item --> | |
</div> <!-- End of .mix --> | |
<?php endwhile;?> | |
<?php endif; | |
// используем сброс данных записи, чтобы восстановить оригинальный запрос | |
wp_reset_postdata(); | |
} ?> | |
<div class="clear_fix"></div> | |
</div> <!-- End of #mixitup_list --> | |
</section> <!-- End of .gallery --> | |
<!-- ============================= /Gallery ===========================--> | |
</div><!-- content --> | |
<?php get_template_part('templates/base-end'); ?> | |
<?php get_template_part('templates/musthave'); ?> | |
<?php | |
do_action('get_footer'); | |
get_template_part('templates/footer'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment