Last active
October 22, 2020 16:43
-
-
Save AntonLitvin/79d6f23e309ca16fe2822bd3932abacc to your computer and use it in GitHub Desktop.
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 | |
// вывод дочерних рубрик и их записей на странице родительской рубрики | |
$parent_id = get_query_var('cat'); ?> | |
<?php | |
$sub_cats = get_categories( array( | |
'child_of' => $parent_id, | |
'hide_empty' => 0 | |
) ); | |
if( $sub_cats ) { | |
foreach ( $sub_cats as $cat ) { ?> | |
<div class="col-md-4"> | |
<?php echo '<h3>'. $cat->name .'</h3>'; ?> | |
<?php # получаем записи из рубрики | |
$posts = get_posts( array( | |
'numberposts' => -1, | |
'category' => $cat->cat_ID, | |
'orderby' => 'post_date', | |
'order' => 'DESC', | |
) ); ?> | |
<ul class="circle-marker-list"> | |
<?php | |
foreach ( $posts as $post ){ setup_postdata( $post ); ?> | |
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> | |
<?php } | |
wp_reset_postdata();?> | |
</ul> | |
</div> | |
<?php } | |
} ?> | |
<?php | |
// Пагинация для кастомных типов записей | |
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
$args = array( | |
'posts_per_page' => 6, | |
'order' => 'DESC', | |
'post_type' => 'MY_POST_TYPE', | |
'paged' => $paged | |
); | |
$my_query = new WP_Query( $args ); | |
if ( $my_query->have_posts() ) : | |
while ( $my_query->have_posts() ) : $my_query->the_post(); ?> | |
<div>POST</div> | |
<?php endwhile; | |
endif; ?> | |
<!-- Pagination --> | |
<div class="page_nav"> | |
<?php | |
$GLOBALS['wp_query']->max_num_pages = $my_query->max_num_pages; | |
the_posts_pagination(array( | |
'type'=>'inline', | |
'screen_reader_text' => __( '' ), | |
'end_size' => 1, | |
'mid_size' => 1, | |
'prev_next' => True, | |
'prev_text' => __('<i class="fa fa-angle-left"></i>'), | |
'next_text' => __('<i class="fa fa-angle-right"></i>'), | |
'add_args' => False | |
)); | |
?> | |
</div> | |
<?php wp_reset_postdata(); ?> | |
<!-- End Pagination --> | |
<?php | |
// карточка товара, слайдер с миниатюрками | |
//на примере bx-slider | |
$images = get_field('galery_item'); | |
if ( $images ): ?> | |
<ul class="bxslider"> | |
<?php foreach( $images as $image ): ?> | |
<li><img src="<?php echo $image['sizes']['gallery']; ?>" alt="<?php echo $image['alt']; ?>" /></li> | |
<?php endforeach; ?> | |
</ul> | |
<div id="bx-pager" class="bx-pager"> | |
<?php $dataSlideIndex = 0; ?> | |
<?php foreach( $images as $image ): ?> | |
<a data-slide-index="<?php echo $dataSlideIndex++ ; ?>" href=""> | |
<img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" /> | |
</a> | |
<?php endforeach; ?> | |
</div> | |
<?php endif; ?> | |
<?php | |
//Вывод миниатюры к рубрике. ACF | |
$queried_object = get_queried_object(); | |
$taxonomy = $queried_object->taxonomy; | |
$term_id = $queried_object->cat_ID; ?> | |
<img class="recovered-photo" src="<?php the_field('banner', $taxonomy . '_' . $term_id);?>" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment