T
T
towncitybr2021-08-30 21:17:00
WordPress
towncitybr, 2021-08-30 21:17:00

How to filter taxonomies?

that
is, display the title of the category,
the items themselves
and pagination (also does not want to work correctly now, extra pages appear where they are not needed)

<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>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Zolin, 2021-08-30
@artzolin

Why are you doing it? Copy the archive.php template from the twentysixteen theme and don't worry

<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 -->

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question