paginate_links () не показывает разбивку на страницы - PullRequest
0 голосов
/ 26 мая 2020

Вот мой код:

<div class="destinationsCards">

        <?php
          $destinations = new WP_Query(array(
            'post_type' => 'destinations',
            'posts_per_page' => 3,
          ));


          while($destinations -> have_posts()){
            $destinations -> the_post();?>

            <div class="dCard"> <!-- Card Start -->
              <div class="cImage">
                <a href="<?php the_permalink(); ?>"><img src="<?php echo esc_url(get_field('image')['url']); ?>" alt="<?php echo esc_attr(get_field('image')['alt']); ?>"></a>
              </div>

              <div class="cInfo">
                <div class="cInfoText">
                  <p style="font-size: 0.9rem; font-weight: 700; color: #747d8c"><span><?php echo get_field('jours') ?> JOURS</span> &bull; <span><?php echo get_field('nuits') ?> NUITS</span></p>
                  <a href="<?php the_permalink(); ?>"><h5 style="color: #2f3542"> <?php the_title(); ?> </h5></a>
                  <p style="font-size: 0.9rem;">A partir de <?php echo get_field('prix') ?> DZD</p>
                </div>

                <div class="imageShareButtons">
                  <a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>" target="_blanc"><i class="facebookBlue fab fa-facebook-f"></i></a>
                  <a href="https://www.facebook.com/dialog/send?link=<?php the_permalink(); ?>&app_id=913151315819800&redirect_uri=<?php echo site_url('/destinations') ?>"><i class="messengerBlue fabBig fab fa-facebook-messenger"></i></a> 
                  <a href="https://web.whatsapp.com/send?text=<?php the_permalink(); ?>" target="_blanc"><i class="whatsappGreen fabBig fab fa-whatsapp"></i></a> 
                </div>
              </div> 
            </div> <!-- Card End -->  

          <?php  
          }

          echo paginate_links();

          wp_reset_postdata();
        ?>

    </div>

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

Этот код взят со страницы архива пользовательского типа сообщения, вот как я объявил этот тип сообщения:

        function postTypes(){
        register_post_type('Destinations', array(
            'show_in_rest' => true, // shows gutenberg
            'supports' => array('title', 'editor'),
            'rewrite' => array('slug' => 'destinations'),
            'has_archive' => true,
            'public' => true,
            'labels' => array(
                'name' => 'Destinations',
                'add_new_item' => 'Ajouter une nouvelle destination',
                'edit_item' => 'Modifier la destination',
                'all_items' => 'Toutes les destinations',
                'singular_name' => 'Destinations'
            ),
            'menu_icon' => 'dashicons-location',
            'menu_position' => 1,
        ));

}
add_action( 'init', 'postTypes')

Ответы [ 2 ]

0 голосов
/ 27 мая 2020

У меня все заработало после того, как я изменил количество блогов в настройках чтения, чтобы оно соответствовало пользовательскому запросу posts_per_page.

0 голосов
/ 26 мая 2020

используйте bootstrap datatable $ (document) .ready (function () {$ ('# example'). DataTable ({"pagingType": "full_numbers"});});

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