0

i have a problem with the pagination in wordpress. I'm having a category-template wich involkes a query for a custom posts. The problem is that when i add a pagination and you go to the next page the pagination add $_GET['paged'] but the template reject it and trow 404 page. I also discovered that if $_GET['paged']=1 everything works fine but if it is 2 or more throw 404 page. The thing is that i try in the index loop and it also does not work. I'm using html5blank theme.

Here is the code to the query:

<section id="inner-pad">
<?php 
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;    
$args = array(
//'posts_per_page' => 6,
'post_type' =>  'menu-pub',
'cat' =>3,
'paged' => $paged,
'order'=>'DESC'
);
$wp_query = new WP_Query( $args );
$i=1;
while ( $wp_query->have_posts() )
{
    $wp_query->the_post();
    ?>
  <article class="article-first-vision <?= ($i==2)?'mar':'' ?>" >
  <?php if ( has_post_thumbnail()) { ?>
  <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
  <?php the_post_thumbnail('menu-pub'); ?>
  </a>
  <?php
}; ?>
  <h2>
    <?php the_title(); ?>
  </h2>
  <p>
    <?php the_content(); ?>
  </p>
  </article>
  <?php
  if($i==3){$i=0;}enter code here
  $i++;
}
?>
    </section>
    <?php 
     $big = 999999999;
     echo paginate_links(array(
    'base' => str_replace($big, '%#%', get_pagenum_link($big)),
    'format' => '?paged=%#%',
    'current' => max(1, get_query_var('paged')),
    'total' => $wp_query->max_num_pages
     ));
     ?>

Here is a new dialog where i put a theme for this:

http://wordpress.org/support/topic/custom-post-and-category-template-pagination-problem?replies=2#post-4560385

0

2 Answers 2

0

try to add global $wp_query before paginate_links()

1
  • Yes i have it. Thanks for the answer that is not the problem. I will try to explain it. So it is nothing wrong with the code. The thing is that when i used in category and make a different attribute 'posts_per_page' => 1 for the Wp_query the pagination get the number from the admin in the Reading setting -> Blog pages show at most "number". So when i tell it to show me only two posts in the category template it differs from the paginations setting. So my solution to this was to inser 1 in Reading setting -> Blog pages show at most and then everything start to work. Commented Aug 8, 2013 at 13:59
0

Hi here is the answer to my question:

add_action( 'parse_query','changept' );
function changept() {
if( is_category() && !is_admin() )
    set_query_var( 'post_type',  array( 'menu-pub', 'new-pub', 'read-pub', 'awards-pub', 'live-pub','post' ));
return;
}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.