Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

it works everywhere on my site but it isnt working in category.php. When i click page to it goes to... domain.com/category/cat-slug/page/2

by the way this is showing custom post types within certain categories (no actual plain 'posts')

But when the page loads its just the 404 page?

When i go to /page/1 it works fine, just not for any other pages.

In permalinks I have /%postname%/ although I have set category base to 'category' just to be safe.

I also know this is kind of a convoluted way of doing it but i wasnt sure a better way.

<?php


get_header(); ?>

<div class="home-gradient">
<div id="container">
<div class="content-wrap">  

<?php 

   $catID = get_query_var('cat');
   $catName = strtolower(get_cat_name($catID));


    if ( get_query_var('paged') ) {
    $paged = get_query_var('paged');
  } elseif ( get_query_var('page') ) {
    $paged = get_query_var('page');
  } else {
    $paged = 1;
  }

  $myquery = new WP_Query(array(
        'post_type' => 'any',
            'paged' => $paged,
            'posts_per_page' => 1,
      'category_name' => $catName)
        );

        while ( $myquery->have_posts() ) : $myquery->the_post(); 


        $img_id = get_post_meta($post->ID,'main_image',true);
        $img_url = wp_get_attachment_url($img_id);

    ?>
blah blah code here for output

    <?php

  endwhile;
   wp_pagenavi( array( 'query' => $myquery ) );
   ?>
share|improve this question
    
Why do you do conditional check for get_query_var( 'paged' )? –  Mamaduka Mar 25 '12 at 10:45
    
I looked around forever for a fix to make pagination work and that's the only thing that worked. I'm not too worried about more efficient ways to do things at this point, i just want to get it working :( –  Tallboy Mar 25 '12 at 15:20
add comment

1 Answer 1

up vote -1 down vote accepted
<?php
$catname = wp_title('', false);
$wp_query = new WP_Query();
$wp_query->query('category_name='.$catname.'&showposts=5'.'&paged='.$paged);
?>

<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<?php the_title(); ?>
<?php } ?>

<?php endwhile; ?>

<?php next_posts_link('&laquo; Older Entries') ?>
<?php previous_posts_link('Newer Entries &raquo;') ?>

I think that you need to look at the $paged variables.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.