vendredi 27 novembre 2015

Wordpress: WpPageNavi only show first page

I have a custom page where I have two loops, I already tried WpPagiNavi and WpPaginate Plugin, the first one only appears when I set to "Always show pagination".

My query:

<?php 
  /* Template Name: Noticias */
  get_header(); 
?>
<!-- ================================== END HEADER -->
  <section id="content" class="row">
    <header class="column large-12 small-12">
      <h1 class="intTitle">Notícias</h1>
      <p class="siteLocal">Home > Notícias</p>
    </header>

    <section class="noticiasDestaque">

    <?php
      $taxonomy = 'category';
      $taxonomy_terms = get_terms( $taxonomy, array(
          'hide_empty' => 0,
          'fields' => 'ids',
          'slug' => 'destaque'
      ) );

      $loop = new WP_Query( array(
          'posts_per_page' => 3,
          'tax_query' => array(
              array(
                  'taxonomy' => $taxonomy,
                  'field' => 'id',
                  'terms' => $taxonomy_terms,
              ),
          ),
      ) );
      while ( $loop->have_posts() ) : $loop->the_post(); 
    ?>
      <a href="<?php the_permalink(); ?>">
        <article class="noticiaDestaque column large-4 medium-12 small-12">
          <div class="box">
            <div class="info">
              <p class="data"><?php the_time('d/m/Y'); ?></p>
              <h1><?php the_title(); ?></h1>
            </div>
            <div class="hover"></div>
            <?php if ( has_post_thumbnail()) : ?>
              <?php the_post_thumbnail( 'noticiadestaque-interna' ); ?>
            <?php endif; ?>
          </div>
        </article>
      </a>
      <!-- END ITEM -->
      <?php endwhile; ?>
      <?php wp_reset_query(); ?>



        <?php 
            $paged = get_query_var('paged') ? get_query_var('paged') : 1;
            #$paged = (get_query_var('paged')) ? get_query_var('paged') : (get_query_var('page') ? get_query_var('page') : 1 );

            $args = array(
                         //  'post_type' => 'post',
                           'posts_per_page' => 6,
                           'paged' => $paged,
                           'post_parent' => $parent
                        );
            $my_query = new WP_Query($args);

            if($my_query->have_posts()):
                while($my_query->have_posts()):$my_query->the_post();

          ?>
      <article class="listaNoticia column large-6 medium-6 small-12">
        <a href="<?php the_permalink(); ?>">
          <p class="data"><?php the_time('d/m/Y'); ?></p> <br><br>
          <h2><?php the_title(); ?></h2>
        </a>
      </article>
      <!-- END ITEM -->
<?php endwhile; endif; ?>

<div class="paginacao column large-12 medium-12 snall-12">
      <div>

        <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>

        <?php if(function_exists('wp_paginate')) { wp_paginate(); } ?>

        <?php wp_reset_query(); ?>


      </div>
    </div>

    </section>
  </section>
<!-- ================================== END CONTENT -->
<?php get_footer(); ?>

I'm tried already to put one at time, and both at the same time.

If I change the url for /page/2/ the pagition works when the page is loaded

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire