title: Wordpress paginate_links() function, 404s and trouble
body: <p>This has been a horrendous, crippling, time stealing (two week) horrible horrible problem. </p>
  
  <p>It might be rewriting, my use of custom posts, but after stripping out so much (and reducing some functionality of my theme) I've reduced my problem to this:</p>
  
  <p><code>paginate_links()</code> is putting out a link like this: </p>
  
  <pre><code>?s=cute&amp;post_type=image&amp;paged=2
  </code></pre>
  
  <p>When I changed the variable in the browser bar to page=2 (dropping the 'd').</p>
  
  <pre><code>?s=cute&amp;post_type=image&amp;page=2 
  </code></pre>
  
  <p>It works correctly.</p>
  
  <p>So my question reduced to this: <strong>If I must get that function to output the "page" variable properly, how is that done?</strong> </p>
  
  <p><code>paged</code> and <code>paged</code> are both used by WordPress. So conversely, how do I get <code>paged</code> recognized if that is better practice?</p>
  
  <p>For all I know, this is indicative of some deeper issue I have in my theme, but for the life of me I can't see how else I could be going wrong! </p>
  
  <p>EDIT: </p>
  
  <p>Here is my code I'm using: </p>
  
  <pre><code>if ( get_query_var('paged') )
  
          $paged = get_query_var('paged');
  
      elseif ( get_query_var('page') )
  
          $paged = get_query_var('page');
  
      else
          $paged = 1;     
  
      $big = 999999999; // need an unlikely integer
  
      $stuff_to_echo =  paginate_links( array(
          'base' =&gt; str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
          'format' =&gt; '?page=%#%',
          'current' =&gt; max( 1, $paged ),
          'total' =&gt; $wp_query-&gt;max_num_pages,
          'type' =&gt; 'array'
      ) );
  </code></pre>
  
  <p>EDIT 2 - If above is good, here is another possible area the problem might be happening. I'll post the creation of the custom post type and the rewrite rules - </p>
  
  <pre><code>//image custom post type
  
  add_action( 'init', 'symbiostock_image_manager_register' );
  
  function symbiostock_image_manager_register( )
  {
      //creating custom post type for image
  
      $labels = array(
           'name' =&gt; 'Symbiostock Images',
          'singular_name' =&gt; 'Image',
          'add_new' =&gt; 'New Image',
          'add_new_item' =&gt; 'Add New Image',
          'edit_item' =&gt; 'Edit Image',
          'new_item' =&gt; 'New Image',
          'all_items' =&gt; 'All Images',
          'view_item' =&gt; 'View Image',
          'search_items' =&gt; 'Search Images',
          'not_found' =&gt; 'No image found',
          'not_found_in_trash' =&gt; 'No images found in Trash',
          'parent_item_colon' =&gt; '',
          'menu_name' =&gt; 'RF Images' 
      );
  
      $args = array(
  
           'labels' =&gt; $labels,
          'singular_label' =&gt; __( 'Image' ),
          'description' =&gt; 'Image Listings',
          'menu_position' =&gt; 100,
          'menu_icon' =&gt; symbiostock_IMGDIR . '/symbiostock_icon2.png',
          'public' =&gt; true,
          'publicly_queryable' =&gt; true,
          'show_ui' =&gt; true,
          'capability_type' =&gt; 'post',
          'hierarchical' =&gt; true,
          'has_archive' =&gt; true,
          'exclude_from_search' =&gt; false,
          'supports' =&gt; array(
               'title',
              'editor',
              'thumbnail' 
          ),
          'rewrite' =&gt; array(
               'slug' =&gt; 'image',
              'with_front' =&gt; false 
          ) 
  
      );
  
  
      register_post_type( 'image', $args );
  
      register_taxonomy( 'image-type', array(
           'image' 
      ), array(
           'hierarchical' =&gt; true,
          'label' =&gt; 'Image Categories',
          'singular_label' =&gt; 'Image Type',
          'rewrite' =&gt; true,
          'exclude_from_search' =&gt;false,
          'public' =&gt; true, 
          'slug' =&gt; 'image-type' 
      ) );
  
      register_taxonomy( 'image-tags', array(
           'image' 
      ), array(
           'hierarchical' =&gt; false,
           'rewrite' =&gt; true,
           'query_var' =&gt; true,
          'singular_label' =&gt; 'Image Keyword',
  
          'hierarchical'            =&gt; false,
          'labels'                  =&gt; $labels,
          'show_ui'                 =&gt; true,
          'show_admin_column'       =&gt; true,
          'update_count_callback'   =&gt; '_update_post_term_count',
  
  
          'slug' =&gt; 'image-tag',               
          'labels' =&gt; array(
              'name' =&gt; _x( 'Image Keywords', 'taxonomy general name' ),
              'singular_name' =&gt; _x( 'Keywords', 'taxonomy singular name' ),
              'search_items' =&gt;  __( 'Search Images' ),
              'all_items' =&gt; __( 'All Image Keywords' ),
              'edit_item' =&gt; __( 'Edit Image Keyword' ),
              'update_item' =&gt; __( 'Update Image Keyword' ),
              'add_new_item' =&gt; __( 'Add New Image Keyword' ),
              'new_item_name' =&gt; __( 'New Keyword Name' ),
              'menu_name' =&gt; __( 'Image Keywords' ),
              ),
          'rewrite' =&gt; array(
              'slug' =&gt; 'search-images', // This controls the base slug that will display before each term
              'with_front' =&gt; false, 
              'hierarchical' =&gt; false 
          ),
      ) );
  
  }
  
  add_action( 'admin_init', 'symbiostock_image_directory' );
  
  function symbiostock_image_directory( )
  {
      add_meta_box( 'symbiostock-image-meta', 'Symbiostock Image Info', 'symbiostock_image_manager_meta_options', 'image', 'normal', 'high' );
  
  }
  </code></pre>
  
  <p>And here are the rewrite rules further down - </p>
  
  <pre><code>add_action( 'init', 'symbiostock_rewrite' );
  
  function symbiostock_rewrite( )
  {   
  
      global $wp_rewrite;
      $wp_rewrite-&gt;add_permastruct('typename','typename/%year%%postname%/' , true , 1);
      add_rewrite_rule('typename/([0-9]{4})/(.+)/?$','index.php?typename=$matches[2]', 'top');
      $wp_rewrite-&gt;flush_rules();
  
  }
  </code></pre>