pagination not working for category.php (custom post types in categories)

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 ) );
   ?>

Solutions Collecting From Web of "pagination not working for category.php (custom post types in categories)"

<?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.