@towncitybr

Как сделать фильтрацию таксономий?

тоесть
вывести название рубрики,
сами итемы
и пагинация (тоже не хочет сейчас работать корректно, лишние страницы появляются где не нужно)

<ul class="report__list"> 
				<li><a href="#"><?php echo $translate[$lang]['main']; ?></a></li>
				<li>название рубрики</li>
			</ul>
			<h3 class="report__title">название рубрики</h3>
			<div class="report__wrap">	
				<?php 

				$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
				
		            $doc_args = array(
		              'post_type' => 'blog',
		              'posts_per_page' => 6,
		              'paged' => $paged
		            );

		            $query = new WP_Query( $doc_args );

		            if ( $query->have_posts() ) {

		              while ( $query->have_posts() ) {
		              	
		                $query->the_post();
		                get_template_part( 'template-parts/doc-item', get_post_format() );
		              }
		            }
		            wp_reset_postdata(); 
		                  
		          ?>    
			</div><!--end report__wrap-->
			<nav class="navigation pagination" role="navigation">
                <div class="nav-links">
					<?php
				        $args = [
						'total'        => $query->max_num_pages,
						'end_size'     => 2,
						'mid_size'     => 2,
						'prev_next'    => True,
						'prev_text'    => __(''),
						'next_text'    => __(''),
									
						];
						echo paginate_links( $args );
				     ?>
			     </div>
         	</nav>
  • Вопрос задан
  • 70 просмотров
Пригласить эксперта
Ответы на вопрос 1
artzolin
@artzolin Куратор тега WordPress
php, WordPress разработка сайтов artzolin.ru
Зачем вы это делаете? Скопируйте шаблон archive.php из темы twentysixteen и не мучайтесь

<main id="main" class="site-main" role="main">

	<?php if ( have_posts() ) : ?>

		<header class="page-header">
			<?php
				the_archive_title( '<h1 class="page-title">', '</h1>' );
				the_archive_description( '<div class="taxonomy-description">', '</div>' );
			?>
		</header><!-- .page-header -->

		<?php
		// Start the loop.
		while ( have_posts() ) :
			the_post();

			/*
			 * Include the Post-Format-specific template for the content.
			 * If you want to override this in a child theme, then include a file
			 * called content-___.php (where ___ is the Post Format name) and that
			 * will be used instead.
			 */
			get_template_part( 'template-parts/content', get_post_format() );

			// End the loop.
		endwhile;

		// Previous/next page navigation.
		the_posts_pagination(
			array(
				'prev_text'          => __( 'Previous page', 'twentysixteen' ),
				'next_text'          => __( 'Next page', 'twentysixteen' ),
				'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>',
			)
		);

		// If no content, include the "No posts found" template.
	else :
		get_template_part( 'template-parts/content', 'none' );

	endif;
	?>

</main><!-- .site-main -->
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы