проблема нумерации страниц с указанием пользовательских типов записей таксономии в WordPress - PullRequest
0 голосов
/ 29 февраля 2020

Я пытаюсь перечислить набор продуктов, которые соответствуют условиям таксономии. Список продуктов в порядке, но Я не могу понять нумерацию своих пользовательских сообщений . Я искал информацию в Google, здесь и во многих других местах, но безрезультатно. Я даже не знаю, как решить эту проблему. Мой файл wordpress называется: taxonomy-видами-seefood. php Этот файл отвечает за перечисление животных seefood и имеет код:

<?php
 $paged = get_query_var('paged') ? get_query_var('paged') : 1;
$posts_per_page = 6;
$offset = ( $paged - 1 ) * $posts_per_page;

$args = array(
        'post_type'      => 'products',
        'post_parent' => '0',
        'tax_query' => array(
            array(
                'taxonomy' => 'species',
                'field'    => 'slug',
                'terms'    => 'seefood',
            ),
        ),
        'orderby'        => 'date',
        'order'          => 'DESC',
        'posts_per_page' => $posts_per_page,
        'post_status'    => array('publish', 'pending', 'draft'),
        'paged'          => $paged,
        'offset'         => $offset
    );

$myposts = new WP_Query($args);

    ?>


<div role="main" id="content" class="content-wrap">
    <div class="container">

        <div id="primary" class="content-area col-md-12 post-list">
            <?php
            echo '<main ';
            if ( $myposts->have_posts() ) {
                echo ' itemscope itemtype="http://schema.org/Blog" ';
            }
            echo ' id="main" class="site-main" role="main">';

            if ( $myposts->have_posts() ) {

                echo '<header class="page-header">';

                echo '</header>';
                echo '<div class="flex-items">';
                while ( $myposts->have_posts() ) {
                    $myposts->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( 'content', get_post_type() );
                }
                echo '</div>';
                wp_reset_postdata(); 
                wpbeginner_numeric_posts_nav($myposts);

            } else {
                get_template_part( 'content', 'none' );
            }
            ?>

Функция wpbeginner_numeric_posts_nav ($ myposts) работает нормально и взято из https://www.wpbeginner.com/wp-themes/how-to-add-numeric-pagination-in-your-wordpress-theme/

И я думаю, что моя переменная $ args верна, но не совсем уверена.

Любой совет будет оценен. У меня есть немного блока.

Спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...