Wordpress getting problem with pagination

I am trying to display pagination from `archive.php` with my custom post type `news` but when I click to Next page I am getting `404 page` **My Custom Post Type Code:**               function codex_custom_init() {       $labels = array(         'name'               => 'News',         'singular_name'      => 'News',         'add_new'            => 'Add News',         'add_new_item'       => 'Add New News',         'edit_item'          => 'Edit News',         'new_item'           => 'New News',         'all_items'          => 'All News',         'view_item'          => 'View News',         'search_items'       => 'Search News',         'not_found'          => 'No news found',         'not_found_in_trash' => 'No news found in Trash',         'parent_item_colon'  => '',         'menu_name'          => '1. News'       );            $args = array(         'labels'             => $labels,         'public'             => true,         'publicly_queryable' => true,         'show_ui'            => true,         'show_in_menu'       => true,         'query_var'          => true,         'rewrite'            => array( 'slug' => 'news' ),         'capability_type'    => 'post',         'has_archive'        => true,         'hierarchical'       => false,         'menu_position'      => null,         'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )       );            register_post_type( 'news', $args );     }     add_action( 'init', 'codex_custom_init' );      and **My Pagination Code:**               <?php          // the query to set the posts per page to 3         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $args = array('posts_per_page' => 2, 'post_type' => 'news' , 'paged' => $paged );         query_posts($args);      ?>          <?php if ( have_posts() ) : while (have_posts()) : the_post(); ?>

<img src="<?php echo get_field('image'); ?>" />

<?php echo the_title(); ?>

<?php echo the_content(); ?>

     <?php endwhile; ?>              <?php next_posts_link(); ?>         <?php previous_posts_link(); ?>     <?php else : ?>          <?php endif; ?>      I am new with WordPress so please some one help me :).


navigation issue

I have an issue with navigation in category.php. Navigation is generated, the problem comes up when I click on the link (2 or Next) to navigate to the Next page of result. I get the 404 page instead of the second page of result. Here, my code:               <?php         $page_number = get_query_var('paged'); //Reading page number         $subject = array(             'post_type' => 'post',             'posts_per_page' => '1',             'cat' => '2',             'paged' => $page_number /*Page number set as subject*/             );         $query = new WP_Query($subject);         if ($query->have_posts() ) : while ($query->have_posts() ) : $query->the_post(); ?>

<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?>

<?php echo get_the_excerpt(); ?>

                  <?php endwhile; ?>           <?php $total_pages = $query->max_num_pages;  /* Total amount of pages */             if ($total_pages > 1){  //more than one page           $current_page = max(1, $page_number);           $big = 999999999;            echo paginate_links(array(  //links for pagination               'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),               'format' => '?paged=%#%',               'current' => $current_page,                'total' => $total_pages,                'prev_text' => 'Previous',                'next_text' => 'Next'              ));         }     wp_reset_query(); ?>             <?php endif; ?>


Pagination doesn't work in custom page template

> **Possible Duplicate:**   >  Pagination not working with custom loop Apparently this is very popular issue. There are already bunch of people offering answers for this. But somehow after hours of searching I still can't get the solution. I hope someone can give me a clue here. Currently I created a page for displaying all post from my custom post types. Here is my page template codes:               <?php           /*     Template Name:custom post type page     */     get_header(); ?>

              <?php            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;               $args = array(                 'post_type'=>array('car','bicycle'),                 'posts_per_page'=> 20,                 'page'=>$paged,                 );              $the_query = new WP_Query( $args);         $num =  $the_query->found_posts;               if($the_query){          if ($the_query->have_posts()) : echo $num;              while ($the_query->have_posts()) : $the_query->the_post();               echo '
'.get_the_title().'
';              endwhile;                  next_posts_link( 'Next', $the_query->max_num_pages );             previous_posts_link('Previous', $the_query->max_num_pages );                     else : $return_string =  'no result';                 endif; wp_reset_query();  wp_reset_postdata();         }             ?>

      The problem here is when I click on the `Next` (or `Previous`), the query result remains same. I noticed that the url have show the page number (`page/2/`,or `page/3/`..etc). And the `found_posts() remains same on each page`, everything seem alright, only the content not showing the correct query object. I also tried add `'max_num_pages'=>2` to the wp_query argument, but still not helping. Anyone idea?


Custom search pagination links not working

I'm trying to create a search form on a custom post-type single page as here http://wpadvancedsearch.com/ but when I turn to the next page pagination is simply reload the page. Here is my code               <?php          $args = array();                  $args['wp_query'] = array('post_type' => 'post',                                                         'post_per_page' => 3,                                             'order' => 'DESC',                                             'orderby' => 'date');                  $args['fields'][] = array('type' => 'search',                                             'label' => 'Search',                                             'value' => '');                               $args['fields'][] = array('type' => 'taxonomy',                                                 'label' => 'Category',                                                 'taxonomy' => 'category',                                                 'format' => 'multi-select',                                                 'operator' => 'AND');                       $args['fields'][] = array('type' => 'submit',                                             'value' => 'Search');                  $my_search_object = new WP_Advanced_Search($args);                  $my_search_object->the_form();                  $temp_query = $wp_query;             $wp_query = $my_search_object->query();                  if ( have_posts() ):                       while ( have_posts() ): the_post();                 ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

Author: <?php the_author();?>    Date: <?php the_date();?>
                     <?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>">Read more...
                 <?php                 endwhile;                   $my_search_object->pagination();                  else :                      echo 'Sorry, no posts matched your criteria.';                  endif;                  $wp_query = $temp_query;             wp_reset_query();         ?>      The code that follows the code of the file mytheme: wpas.php (wp-advanced- search/wpas.php):                /**          * Initializes a WP_Query object with the given search parameters          *          * @since 1.0          */         function query() {             $this->build_tax_query();             $this->build_meta_query();             $this->convert_orderby();                  // Apply pagination             if ( get_query_var('paged') ) {                 $paged = get_query_var('paged');             } else if ( get_query_var('page') ) {                 $paged = get_query_var('page');             } else {                 $paged = 1;             }             $this->wp_query_args['paged'] = $paged;                  $this->wp_query = new WP_Query($this->wp_query_args);                  $query = $this->wp_query;             $query->query_vars['post_type'] = $this->wp_query_args['post_type'];                  if ($this->relevanssi) {                 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );                 if (!empty($_REQUEST['search_query']) && is_plugin_active('relevanssi/relevanssi.php')) {                     relevanssi_do_query($query);                 }             }                  if (defined('WPAS_DEBUG') && WPAS_DEBUG) {                 echo '
';                 print_r($query);                 echo '
';             }                  return $query;         }                   /**          * Displays pagination links          *          * @since 1.0          */         function pagination( $args = '' ) {             global $wp_query;             $current_page = max(1, get_query_var('paged'));             $total_pages = $wp_query->max_num_pages;                  $big = '999999999';             $base = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) );                  $defaults = array(                             'base' => $base,                             'format' => 'page/%#%',                             'current' => $current_page,                             'total' => $total_pages                         );                  $args = wp_parse_args($args, $defaults);                  if ($total_pages > 1){                 echo '
';                 echo paginate_links($args);                 echo '
';             }              }              /**          * Displays range of results displayed on the current page.          *          * @since 1.0          */         function results_range( $args = array() ) {             global $wp_query;                  $defaults = array(                             'pre' => '',                             'marker' => '-',                             'post' => ''                         );                    $args = wp_parse_args($args, $defaults);                 extract($args);                  $total = $wp_query->found_posts;             $count = $wp_query->post_count;             $query = $wp_query->query;             $ppp = (!empty($query['posts_per_page'])) ? $query['posts_per_page'] : get_option('posts_per_page');             $page =  get_query_var('paged');             $range = 1;                  $range = $page;             if ($ppp > 1) {                 $i = 1 + (($page - 1)*$ppp);                 $j = $i + ($ppp - 1);                 $range = sprintf('%d%s%d', $i, $marker, $j);                 if ($j > $total) {                     $range = $total;                 }              }                  if ($count < 1) {                 $range = 0;             }                  $output = sprintf('%s %s %s', $pre, $range, $post);                  return $output;         }


Pagination problem - multiple loops conflict with wordpress default Post per Page

I have created a Custom Post Type (named: item) and two loops in that. First for showing Stickies, and second for other posts. My code works fine with this but: I want to show 16 of them on each page (stickies + other = 16) and then have pagination for the rest (stickies should appear only at the first page). When I set number of posts in `options-reading.php` to 1, additional pages with blank content appear in pagination. Also I can't set 16 posts for both Stickies and Others together. This is my code:               <?php $counter = 1; //start counter     $paged = get_query_var('paged');        if ($paged < 2 ) {        $sticky = get_option('sticky_posts');        $most_recent_sticky_post = new WP_Query(array(                  'post__in' => $sticky,             'ignore_sticky_posts' => 1,             'post_type' => 'item',             'orderby' => ID,             'posts_per_page' => -1,             'paged' => $paged,             'post_status' => 'publish',              ));        while ($most_recent_sticky_post->have_posts()) : $most_recent_sticky_post->the_post();?>                  // the content                  <?php if ($counter % 4 == 0) { echo '

'; } ?>          <?php $counter++; endwhile; wp_reset_query(); ?>          <?php } // endif $paged ?>                   <?php           $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $all_other_posts = array(             'post__not_in' => get_option('sticky_posts'),             'post_type' => 'item',             'posts_per_page' => 2,             'paged' => $paged,             'post_status' => 'publish',         );         global $wp_query;         $merged_query_args = array_merge($wp_query->query, $all_other_posts);         query_posts($merged_query_args); ?>         <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                  // the content                  <?php if ($counter % 4 == 0) { echo '

'; } ?>         <?php $counter++; endwhile; endif; wp_reset_query(); ?>      I'm using WP 3.5.2 and new to PHP concepts.


WordPress site with custom theme, can't get pagination to update posts on page 2+

I have inherited a WordPress site which has a custom theme which I have in the main been able to modify to suit the clients needs. I am having trouble, however, with the pagination of the 'category-blog.php' page I have created. The pagination seems to be working in that blog/page/2/ is added to the URL (I have added some debugging code which proves the pagination works), but the posts (which are set to view 10 at a time) never update and the page only ever shows the most recent 10 posts no matter what page you navigate to.               <?php     /** Template Name: blog **/          get_header(); ?>

          <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>     <?php query_posts( 'cat=1' ); ?>
Blog Posts
                         <?php if ( $paged < 2 ) : ?>
Text for first page of Blog Listing. Used for debugging. Will be removed.
     <?php else : ?>
Text for subsequent pages of Blog Listing. Used for debugging. Will be removed.
     <?php endif; ?>               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>

<?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?>
               <?php the_excerpt(); ?>

          <?php endwhile; else: ?>               <?php endif; ?>          <?php if (show_posts_nav()) : ?>
         <?php next_posts_link('« Older Entries'); ?>         <?php previous_posts_link('Newer Entries »'); ?>
     <?php endif; ?>

          <?php get_sidebar(3); ?>     <?php get_footer(); ?>      Any help with getting the above code to work would be much appreciated. Been banging my head on the desk for hours with this one. Craig


Fix Pagination Directory on a page set as Front Page/Main Page

I have a page named "calientes" with a complex loop that's working perfectly. This page is located at domain.com/calientes/. Now I need to use this page as the home page, so I went to "Settings -> Reading" and chose that page as static page. The problem now is that the pagination no longer works. On the actual page it shows like domain.com/calientes/page/2 and it work perfectly! but now it shows as domain.com/page/2/ when i really want to go to domain.com/calientes/page/2 I didn't do any other changes, just chose that page as front page basically. What can i do to made my pagination call domain.com/calientes/page/2? This is my query on my page "Calientes" :               $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;          $args = array(       'posts_per_page' => 9,       'paged' => $paged,       'meta_query' => array(          array(            'key' => '_wti_like_count',            'value' => 10,            'compare' => '>=',            'type' => 'numeric'          )       )     );          $wp_query = new WP_Query();     $wp_query->query( $args );          if( have_posts() ) : ?>          <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>          <?php get_template_part( 'content', get_post_format() ); ?>     <?php comments_template( '', true ); ?>     <?php endwhile; // end of the loop. ?>          <?php twentytwelve_content_nav( 'nav-below' ); ?>


Paged within a custom content type template

I'm having a huge problem a custom query within a custom post type template with regards to pagination. For some reason, the previous post, next post links are showing blank. If I do "www.domainname.com/wolf/spot/paged/2/ it shows a 404 page. The code is below... as I said above, this is a custom query, WITHIN a custom post type template.
          <?php if (have_posts()) : while (have_posts()) : the_post(); ?>              <div class="post" id="post-<?php the_ID(); ?>">
<?php the_title(); ?>

                 <?php the_content('
Read the rest of this entry »
'); ?>
Recent Logs for <?php the_title(); ?>:
                      <?php                 wp_reset_postdata();                 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                      if (isset($_GET['show'])) {                     $ppp = $_GET['show'];                 } else {                     $ppp = 10;                 }                      if (isset($_GET['archyear'])) {                     $archYear = $_GET['archyear'];                 } else {                     $archYear = date("Y");                 }                      $wolf = strtolower(get_the_title());                 $logArgs = array(                             'post_type' => 'wolf-log',                             'post_status' => 'publish',                             'orderby' => 'meta_value_num',                             'meta_key' => 'observationDate',                             'posts_per_page'=> $ppp,                             'meta_query' => array(                                                 'relation' => 'AND',                                                 array(                                                     'key' => 'wolf',                                                     'value' => $wolf,                                                     'compare' => '='                                                 ),                                                 array(                                                     'key'       => 'observationDate',                                                     'type'      => 'numeric',                                                     'value'     => array($archYear.'0101',$archYear.'1231'),                                                     'compare'   => 'BETWEEN'                                                 )                                             ),                             'order' => 'DESC',                             'paged' => $paged                 );                           $wlQuery = new WP_Query($logArgs);                      if ($wlQuery->have_posts()) {                     while ($wlQuery->have_posts()) {                         $wlQuery->the_post();                         get_template_part('loop', 'wolflogs');                     } // endwhile                           ?>

<?php next_posts_link('< Older Posts', $wlQuery->max_num_pages); ?>

<?php previous_posts_link('Newer Posts >', $wlQuery->max_num_pages); ?>

                 <?php                    } else {                     echo '
No current logs, check back later.
';                 }                      // Restore original Post Data                 wp_reset_postdata();                 ?>
                     <?php                         $archArray = array();                         $archArgs = array(                                     'post_type'         => 'wolf-log',                                     'post_status'       => 'publish',                                     'meta_key'          => 'wolf',                                     'meta_value'        => $wolf,                                     'order'             => 'DESC',                                     'posts_per_page'    => -1                                     );                              $archQuery = new WP_Query($archArgs);                              if ($archQuery->have_posts()) {                             while($archQuery->have_posts()) {                                 $archQuery->the_post();                                 $obDate = get_post_meta($post->ID, 'observationDate', true);                                 $obDate = strtotime($obDate);                                 $obDate = date("Y", $obDate);                                 $archArray[$obDate] = $obDate;                             }                         } else {                             echo 'No Archives';                         }                              wp_reset_postdata();                         ?>
                                  <select name="archivesPager" id="archivesPager">                                 <option value="">Archive</option>                                 <?php                                     arsort($archArray);                                     foreach($archArray as $archYear) {                                         echo '<option value="?archyear='.$archYear.'">'.$archYear.'</option>';                                     }                                 ?>                                  </select>

                      <?php                 // Restore original Post Data                 wp_reset_postdata();                      ?>

     <?php endwhile; else: ?>
Sorry, no posts matched your criteria.


Pagination for custom post type not working

> **Possible Duplicate:**   >  Pagination not working with custom loop So I have a post type called portfolio, but I can't get it to paginate. I'd also like it to paginate on single pages so each item has a prev/next link at the bottom, but this won't work either. I try adding this on the single page and the links just don't appear. I've been banging my head against a brick wall for days now trying to find a solution for this and nowhere online can I find one.
<?php next_posts_link('Older Posts') ?>

<?php previous_posts_link('Newer Posts') ?>
                         <?php                                      $portfolio_query = new WP_Query(array(                                     'post_type' => 'portfolio',                                     'showposts' => -1                                     ) );                                ?>                                          <?php while ($portfolio_query->have_posts()) : $portfolio_query->the_post(); ?>                                      <?php global $more; $more = 0; ?>
                                   <a href="<?php the_permalink() ?>">

<?php the_title(); ?>

                                          <?php                                             $posttags = get_the_tags();                                             if ($posttags) {                                               foreach($posttags as $tag) {                                                 echo '
' .$tag->name. '
';                                                }                                             }                                             ?>

                                          <?php the_post_thumbnail(); ?>

                                <?php endwhile; wp_reset_query(); ?>


Pagination problem with custom taxonomies

My previous developer made me a theme but he does not work for me anymore. He made pagination but it does not work. He used GET parameters as search terms which search through custom taxonomies. At the end of URL he adds hidden string, eg: site_section=template. If I remove that last GET parameter from URL pagination works but my search terms get ignored then. This is snipped from functions.php where he used site_section=template.               // USE SPECIAL TEMPLATE FOR TAXONOMIES     add_filter('template_include', 'my_template');     function my_template( $template ){          //Array of taxonomies to check     $taxes = array('ratnig', 'location', 'additional');          if (is_tax($taxes)) {         $alternate = locate_template('special-tax.php');         if(!empty($alternate))         $template = $alternate;     }          // USE SEPARATE PAGE TEMPLATE FOR SEARCH     if(isset($_GET["site_section"])) {         if ($_GET["site_section"] == 'template') {             $alternate = locate_template('search-template.php');             if(!empty($alternate))             $template = $alternate;         }     }          return $template;         }      He also used kriesi pagination in functions.php:                // PAGINATION BY KREISI      function kriesi_pagination($pages = '', $range = 2)      {        $showitems = ($range * 2)+1;             global $paged;      if(empty($paged)) $paged = 1;           if($pages == '')      {          global $wp_query;          $pages = $wp_query->max_num_pages;          if(!$pages)          {              $pages = 1;          }      }              if(1 != $pages)      {          echo "
";          if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "«";          if($paged > 1 && $showitems < $pages) echo "‹";               for ($i=1; $i <= $pages; $i++)          {              if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))              {                  echo ($paged == $i)? "".$i."":"".$i."";              }          }               if ($paged < $pages && $showitems < $pages) echo "›";            if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "»";          echo "
\n";      }      } I tried with default wordpress pagination (older, newer posts) but same result. My URL looks like this: http://www.site.com/search/page/3/?rating=5&location&site_section=template and pagination does not work like this. If I remove **site_section=template** search terms are not taken and I see all the results but pagination works! Is there any workaround? Is there anything else I should post here? I have been trying so hard, googling for days with no luck!


Custom pagination

I'm using template part for showing portfolio items. It's not page template just portfolio.php file and I'm included it with `get_template_part('portfolio');` to homepage. Now everything is working good. But I want to use pagination for this section. Here is my code block;               <?php     global $wp_query;     $paged = get_query_var('paged') ? get_query_var('paged') : 1;     $port_args = array(             'post_type'     => 'portfolio',             'posts_per_page'  => 3,             'post_status'     => 'publish',             'paged'       => $paged     );     $wp_port_query = new WP_Query($port_args);          if( have_posts() ) :         while ( $wp_port_query->have_posts() ) : $wp_port_query->the_post();             ?>             <li class="col-lg-4 col-sm-4 view item <?php $terms = get_the_terms( get_the_ID(), 'portfolio_filter' ); ?><?php if($terms) : foreach ($terms as $term) { echo $term->slug.' '; } endif; ?>">                      <?php the_post_thumbnail("portfolio-image"); ?>
             <?php         endwhile;     endif;          echo '';     echo  '
'.get_next_posts_link('Older', $wp_port_query->max_num_pages).'
'; //Older Link using max_num_pages     echo  '
'.get_previous_posts_link('Newer', $wp_port_query->max_num_pages).'
'; //Newer Link using max_num_pages     echo "";          wp_reset_query();     ?>      When I click the Older pagination button it's going to `?paged=2`, but it's not working it shows same posts again. If I use the page template and open the `themename/page_id=82` directly it's working. And url looking like this `?page_id=82&paged=2` now I'm thinking I missing page id on section. How can I fix this and work it in homepage template section. If it's not working how can I add the page_id in get_next_posts_link . It's looking like this now `?paged=2` and I want to change it like this `?page_id=82&paged=2`. Page id is coming automaticly from page. How can I do this?


Pagination not shown at index page but displayed at other pages

Somehow my pagination is not shown on the index page of a customised page template. But it does show the previous / next posts links on the other pages like mypage/paged/2/ This is the code that I'm using:               <?php // the query          $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                  $the_query = new WP_Query(      array(      'posts_per_page' => '2',      'cat' => '6',     'paged' => $paged     ) ); ?>          <?php if ( $the_query->have_posts() ) : ?>          <!-- the loop -->     <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>          <!-- content goes here -->          <?php endwhile; endif; ?>          <!-- end of the loop -->     <?php next_posts_link ('Older posts'); previous_posts_link ('Newer posts'); ?>          <?php wp_reset_query(); ?>      Any clue why this isn't fully working? Edit: the solution posted in the duplicate question link didn't solve the issue but this solution did solve it:               global $wp_query;          $paged = 1;     if ( get_query_var('paged') ) $paged = get_query_var('paged');     if ( get_query_var('page') ) $paged = get_query_var('page');


Pagination broken at search results page

Common problem, yet this time I can't seem to figure it out: the pagination at my search.php is not working, it sends me to the index page the moment I click on "page #" My search.php is set up like described by wordpress http://codex.wordpress.org/Creating_a_Search_Page :                <?php     global $query_string;     $query_args = explode("&", $query_string);     $search_query = array();     foreach($query_args as $key => $string) {         $query_split = explode("=", $string);         $search_query[$query_split[0]] = urldecode($query_split[1]);     }      $search = new WP_Query($search_query);     $total_results = $search->found_posts;          if ( $search->have_posts()) :          echo $total_results;         wp_page_numbers();          while ($search->have_posts()) : $search->the_post();         get_template_part( 'content', get_post_format() );     endwhile; ?>      Then the pagination function in functions.php:               function wp_search_numbers() {     global $wp_query, $wp_rewrite;     $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;          $pagination = array(         'base' => @add_query_arg('paged','%#%'),         'format' => '',         'total' => $wp_query->max_num_pages,         'current' => $current,         'show_all' => true,         'type' => 'list',         'next_text' => '»',         'prev_text' => '«'         );          if( $wp_rewrite->using_permalinks() )         $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );          if( !empty($wp_query->query_vars['s']) )         $pagination['add_args'] = array( 's' => get_query_var( 's' ) );          echo paginate_links( $pagination );     }      The pagination on index, taxonomy and other custom pages work fine. I have tried several things, like adding: // Pagination fix $temp_query = $wp_query; $wp_query = NULL; $wp_query = $custom_query; But that changes my search results to zero. Also tried resetting the permalinks, which didn't change anything. And I removed the **$wp_query = new WP_Query();** and went for the general **query_posts( $args );** without any change. The strangest thing is that I just found out, it's not for all the numbers in the pagination. If I do a search query with a results of 15 pages: Page 3 and 8 - 15 work, but not page 2 - 5. Could anyone tell me in what direction I should look for the error?


Pagination on Custom Gallery Template : get_children() and foreach loop

With the help of this WordPress.org Support Thread, I made a Page Template for a custom designed photo gallery of 4 columns with the following codes in a TwentyThirteen theme:               <?php     /*     Template Name: Gallery      */          get_header(); ?>

                      <?php                 $images = get_children(                     array(                         'post_parent' => $post->ID,                         'post_status' => 'inherit',                         'post_type' => 'attachment',                         'post_mime_type' => 'image',                         'order' => 'ASC',                         'orderby' => 'menu_order'                     )                 ); ?>                 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<?php the_title(); ?>

                     <?php                     $divPlacer = 1;                     if ( $images ) {                         foreach ( $images as $id => $image ) {                             $img = wp_get_attachment_thumb_url( $image->ID );                             $imgfull = wp_get_attachment_url( $image->ID );                             $link = get_permalink( $post->ID );                                  $class = ( $divPlacer % 4 == 1 ? ' new_row' : '' );                             $first = ( $divPlacer < 5  ? ' first_row' : '' );                                  ?>                              <div class="my_column<?php echo $class; echo $first; ?>">
                                 <a href="<?php echo $imgfull; ?>" title="<?php echo $image->post_excerpt; ?>">                                     <img class="thumb" src="<?php echo $img; ?>" alt="gallery-thumbnails" />

<?php echo $image->post_excerpt; ?>

                              <?php                         $divPlacer++;                         } //endforeach                              // to enable pagination                         twentythirteen_paging_nav();                     }                     ?>

          <?php get_sidebar(); ?>     <?php get_footer(); ?>      I can understand that I can't let the `foreach()` loop to understand the WordPress pagination (`twentythirteen_paging_nav()` here). So my question[s] is/are:   * How to paginate in this particular situation? (Do I need a custom PHP pagination, like this?)   * Otherwise, how can I achieve such a Gallery with `WP_Query()` or the like?


Custom Category Page Not Working

Under "Settings" => "Reading", I have set "Blog pages show at most" to 6. I have created a category called 1970s where one can see all the best Rock albums of the decade -> Meanwhile, I have created subcategories (1970, 71, 72, 73 etc...) where one can see the best albums of the respective year. Here is the problem(s), in the subcategories I am getting exactly the same results as in the parent category + pagination is not working. I am using the Genesis Framework and I am working with the Sample theme, Here is my custom category.php file:               function rock_custom_loop() { ?>
The Verybest of the:  <?php echo single_cat_title( '', false ) ?>
                  <?php if ( category_description() ) :  ?>
<?php echo category_description(); ?>
             <?php endif; ?>                            <?php         global $post;              $args = array(             'post_type'      => 'post',             'post_status'    => 'publish',             'paged'          => get_query_var( 'paged' )         );              global $wp_query;         $wp_query = new WP_Query( $args );              if ( have_posts() ) :             while ( have_posts() ) : the_post(); ?>

                         <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('category-thumb-2'); ?>

<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?>

                  <?php             endwhile;             do_action( 'genesis_after_endwhile' );         endif;              wp_reset_query();     }          add_action( 'genesis_loop', 'rock_custom_loop' );     remove_action( 'genesis_loop', 'genesis_do_loop' );               genesis();      So I hope you can help find the bug (Subcategories + pagination)! I have attached the following 2 pictures for visualization ![Parent Category](http://i.stack.imgur.com/zcRAY.png) ![enter image description here](http://i.stack.imgur.com/XfkVE.png)


how can I display all post using query_posts?

I created a template page to display my posts. My problem is I get 10 post on my page and after those 10 post i have option to click old entries and when I click it, I get the same post again instead of another 1o posts. I have the following code.               <?php query_posts('showposts=10&paged=' . get_query_var('paged'));?>       <?php query_posts('showposts=10'); ?>      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>      May be anyone could help me get all the posts . I am new to PHP so may be it has nothing to do with above code. Any comments?


Pagination on custom post type with 2 wp_queries

Im trying to get my pagination on a page that lists all custom post types working. I have tried both the bones theme next/prev as well as the default wordpress option, to no avail. This is the two loops in the Page template as is, just removal of the html markup has been removed.               //get Latest post & display in the hero area     <?php $topPost1 = new WP_Query('post_type=in_the_press&posts_per_page=1');     while ($topPost1->have_posts()) : $topPost1->the_post(); $do_not_duplicate = $post->ID; ?>     //do something           <?php endwhile; ?>     <?php wp_reset_query(); ?>          //exclude the latest posts and display the rest     <?php $mainPosts = new WP_Query('post_type=in_the_press&posts_per_page=3'.'&paged='.$paged);     while ($mainPosts->have_posts()) : $mainPosts->the_post(); if( $post->ID == $do_not_duplicate ) continue; ?>     <?php endwhile;  ?>          <?php next_posts_link();?> <?php previous_posts_link();?>


Pagination won't go to page 2

I've created a page which uses posts 2 posts and pagination The pagination will not go to page 2, every time I click the link it reloads the page, however hovering over the page two link shows the correct url(/page/2)               $args=array(         'post_status'       => 'publish',             'post_type'         => 'products',             'connected_type'    => 'product_to_category',             'connected_items'   => $post,             'order'             => 'ASC',             'order_by'          => 'menu-order',             'posts_per_page'    => '10',             'paged'             => (get_query_var('paged')) ? get_query_var('paged') : 1     );     $temp = $wp_query;     $wp_query= null;     $wp_query = new WP_Query($args);               endwhile; endif;                     /* PageNavi at Bottom */                     if (function_exists('wp_pagenavi')){wp_pagenavi();}                     $wp_query = null;                     $wp_query = $temp;                     wp_reset_query();         Custom post type               register_post_type('category',         array(             'labels' => array(                 'name' => __('Categories'),                 'singular_name' => __('Category'),                 '_builtin' =>  false, // It's a custom post type, not built in!             ),             'public' => true,             'has_archive' => true,             'hierarchical' => false,             'supports' => array(                 'title', 'editor', 'thumbnail', 'excerpt'             )         )     );      Does anyone know why this would be happening?


Why won't my paged wp_query work?

> **Possible Duplicate:**   >  Pagination not working with custom loop Any ideas why this paged `wp_query` doesn't seem to want to work? I've tried replacing the `pt_pagination` function with the default next/prev posts links and that didn't work either...               <?php      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array (         'post_type' => 'pt-portfolio',         'paged' => $paged,     );     $pt_portfolio_loop = new WP_Query($args);     while($pt_portfolio_loop->have_posts()) : $pt_portfolio_loop->the_post();     ?>          <?php     $cols = of_get_option('pt_portfolio_layout');     get_template_part('portfolio', $cols);     ?>          <?php endwhile; ?>          <?php pt_pagination(); ?>          <?php wp_reset_postdata();?>


Add pagination to my custom loop

Any tips on fitting pagination into my loop below and I owe you a beer or two. I've worked out how to pull the top rated articles by vote from a custom plugin, and lay it out with a count, but pagination has me stumped. I'm a self-taught learner here so any help would be greatly appreciated. I was aiming for 6 posts shown per page then use pagination if needed. Two posts are shown and after that a new code section is inserted with a count, the count works, everything works except pagination. Not sure how this fits in               '$wp_query->query('showposts=6'.'&paged='.$paged);       when I already use               DESC LIMIT 6 OFFSET 0      in my query...               <?php global $wpdb;     $query_sql = "SELECT like_pid FROM " . $wpdb->prefix ."likes_count ORDER BY like_count DESC LIMIT 6 OFFSET 0";     $query_result = $wpdb->get_col( $wpdb->prepare ($query_sql, OBJECT));     if ($query_result) {     foreach ($query_result as $post_id) {     $post = &get_post( $post_id );     setup_postdata($post); ?>          <?php $count++;     if ($count%2== 0) : ?>          <-- do the loop, count out two articles -->          <?php else : ?>          <-- do something after every two articles -->          <?php endif;?>          <?php } ?>     <?php } ?> //ugly but works
 <?php next_posts_link('»' ,0); ?>

 <?php previous_posts_link('«' ,0); ?>


Pagination to take load off server

I have a Wordpress powered site that has >2000 posts. For some menu items I am requesting a category page that pulls in up to 200 posts in that category. It presents snippets of the post with an automatically added and resized image (the first image of that post grabbed via the pcrmbimagegrab function mentioned below). Because this has a heavy effect on the server each time a visitor looks at the page, I want to add pagination. Here is what my existing category-catname.php code was:

             <?php $recent = new WP_Query("cat=76&showposts=200"); while($recent->have_posts()) : $recent->the_post();?>
                 <a href="<?php the_permalink() ?>" rel="bookmark"><img src="<?php echo pcrmbimagegrab() ?>" alt="<?php the_title(); ?>" />

<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?>
                  <?php the_content_limit(190, ""); ?>                                     <?php $customField = get_post_custom_values("price");                       if (isset($customField[0])) {                       echo "Price: ".$customField[0];                      echo "   ";                     } else {                      ;                     }                     ?>                       <?php $customField = get_post_custom_values("sku");                       if (isset($customField[0])) {                       echo "|   Stock Reference: ".$customField[0] . "   ";                     } else {                      ;                     }                     ?>                  <a class="postbutton" href="<?php the_permalink() ?>" rel="bookmark">View

      Now, because I saw that showposts was deprecated and that pagination didn't seem to work I rewrote it to this:               <?php     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array( 'cat' => 76, 'posts_per_page' => 10, 'paged' => $paged );     $temp = $wp_query;     $wp_query= null;     $wp_query = new WP_Query();     $wp_query->query($args);     if ( $wp_query->have_posts() ) :     while ($wp_query->have_posts()) : $wp_query->the_post();     ?>
         <a href="<?php the_permalink() ?>" rel="bookmark"><img src="<?php echo pcrmbimagegrab() ?>" alt="<?php the_title(); ?>" />

<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?>
     <?php the_content_limit(190, ""); ?>                             <?php $customField = get_post_custom_values("price");               if (isset($customField[0])) {               echo "Price: ".$customField[0];              echo "   ";             } else {              ;             }             ?>               <?php $customField = get_post_custom_values("sku");               if (isset($customField[0])) {               echo "|   Stock Reference: ".$customField[0] . "   ";             } else {              ;             }             ?>           <a class="postbutton" href="<?php the_permalink() ?>" rel="bookmark">View

              <?php         endwhile;         previous_posts_link( 'Previous items ' );         next_posts_link( 'More items ', $wp_query->max_num_pages );         endif;         $wp_query = null; $wp_query = $temp;         ?>      This truncates the displayed posts to 10 on a page perfectly. The problem is that I want to display the subsequent 10 posts with the pagination links and currently the 'More items' link takes me to /category/category-name/page/2/ which results in a 404 error. Note to mods: I have searched StackExchange and can't see anyone else doing paginated category pages this way, although there is 'next post' information. Ideally I would like a list of pagination numbers but just getting the 'more items' link working would be a great help. How is this best achieved? Thanks in advance.


Custom Post Type Pagination for Bones Theme

I am trying to implement pagination to my custom post type and I am using the bones theme framework as well as their function they provide for pagination. Here is my code               $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array(         'post_type' => 'custom_type',         'posts_per_page' => '5',         'paged' => $paged     );     $wp_query = new WP_Query( $args );     if ( $wp_query->have_posts() ) :         while ( $wp_query->have_posts() ) :             $wp_query->the_post();?>                  //DO STUFF HERE              endwhile;         if ( function_exists( 'bones_page_navi' ) ) {             bones_page_navi();          } else {              next_posts_link( __( '« Older Entries', 'bonestheme' ));             previous_posts_link( __( 'Newer Entries »', 'bonestheme' ));         }     endif;


How Do I Configure Automatic Updates in WordPress 3.7?

WordPress 3.7 added automatic updates. How does this work, and how can I configure this feature?


Problem: ( kriesi ) pagination doesn't work in homepage

When I set this template as homepage, pagination doesn't work. I see the buttons, but when I click the button for page 2, nothing happens, doesn't go on page 2, it still remain in page 1. **What is wrong? Where is the mistake?**   _I read all posts from here & from internet about this issue, but nothing works._ Solution for pagination is this: **kriesi**. **Here is the code:**

                      <?php if (have_posts()) : while (have_posts()) : the_post();?>                      <?php                    $template_name =   get_post_meta( $wp_query->post->ID, '_wp_page_template', true );                 $post_type =  str_replace( array('template-', '.php'), array(''), $template_name);                 ?>                      <?php the_content(); ?>                      <?php endwhile; endif; ?>                 <?php                  $loop = new WP_Query("post_type=$post_type&paged=$paged");                 if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post(); ?>                       <?php get_template_part('loop', $post_type) ?>                                                      <?php endwhile; ?>                                             <?php else: ?>                     <?php require THEME_DIR.'/empty.php'; ?>                                            <?php endif; ?>                                                      <?php pagination($loop->max_num_pages); ?>
                  <?php get_sidebar(); ?>


Wordpress custom loop and wp_pagenavi

My code is the following:               function blog_pagecustom() {              if (is_page(703))                {         global $wp_query;              $args = array(             'post_type' => 'post',             'posts_per_page' => 4,             'post__not_in'  => $sticky,             'paged' => get_query_var('paged')         );         $wp_query = new WP_Query( $args );                  if ( $wp_query->have_posts() ) :                 while ( $wp_query->have_posts() ) : $wp_query->the_post();                          some staff...                      endwhile;             endif;                   }       }      After this code I added a function which is called after the content, it goes like this:               function page_navigation() {          ?>

                 <?php wp_pagenavi(); ?>                 <?php wp_reset_query(); ?>

     <?php               }          add_action('thesis_hook_after_content_area', 'page_navigation');      I can see the posts as I should, but I can see them twice and after that I see the `page_navi` pagination. I break my head here, I reaf previous posts on the issue but no luck. Any thoughts ? Why they appear twice ?


2 Loops in wordpress problem

I have in the same page in wordpress with 2 loop. Each loop resolve for a category. The first loop only have 20 post, but the second loop have more than 1000. When I advanced with the navigator, the second page and other show only the result of second loop and the first look is empty. How can I do for show in the second page, third... the first loop (The only 20 post of that loop? thanks.


How do I automagically use <!--nextpage--> in custom page template?

I have searched a lot now and not found a real solution that helps me with this: I am creating a custom page template for an archive page. This (static) page will show _all_ my blog posts ordered by year & months. I figured that this is already a long list of about 500 posts, so I decided that I would want a "paginated" archive page with 75 posts each. But i cannot figure out, how to use the `<!--nextpage-->`-shortcode in my php template. I inserted as show below, and it only works 50%. It "ends" the current page, but does not add the links for the following pages.
     <?php         $all_posts = get_posts(array(             'posts_per_page' => -1 // to show all posts         ));              // this variable will contain all the posts in a associative array         // with three levels, for every year, month and posts.              $ordered_posts = array();         $post_count = 0;              foreach ($all_posts as $single) {             $year  = mysql2date('Y', $single->post_date);             $month = mysql2date('F', $single->post_date);                  // specifies the position of the current post             $ordered_posts[$year][$month][] = $single;              }              // iterates the years         foreach ($ordered_posts as $year => $months) { ?>
<?php echo $year ?>

             <?php foreach ($months as $month => $posts ) { // iterates the moths ?>

<?php printf("%s " . $year . " (%d)", $month, count($months[$month]));?>

                     <?php if ( ! has_category( is_category( pinboard_get_option( 'portfolio_cat' ) ) ) ):                     foreach ($posts as $single ) { // iterates the posts ?>
                             <a href="<?php echo get_permalink($single->ID); ?>" class="article"><?php echo get_the_title($single->ID); ?> - <?php $categories = get_the_category($single->ID);                             $separator = ' ';                             $output = '';                             if($categories){                                 foreach($categories as $category) {                                         $output .= 'term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" class="category">'.$category->cat_name.''.$separator.'['.$post_count.']';                                     }                                     echo trim($output, $separator);                                 }                                 $post_count++;                                 /*                                 if ( $post_count > 75 ):                                     return '';                                 endif;                                 // Kinda works: ends "page" but does not add pagination                                 */                                 ?>
                     <?php }                     endif; // ends foreach $posts ?>

             <?php } // ends foreach for $months ?>
          <?php } // ends foreach for $ordered_posts ?>

     <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'pinboard' ), 'after' => '
' ) ); ?>


Shortcode does not display pagination

I use a normal page for display posts by a shortcode.On pages posts are displayed correctly,but doesn't echo the next and previous posts links and the page content is displayed below shortcode content. In admin:
page content
     [ accomodation-catalog location='slug ' accomodation='slug']      display
shortcode content

page content
      What is wrong? My shortcode in function.php ->               function accomodation_catalog_shortcode( $atts )     {     extract(shortcode_atts(array(          'accomodation' => '',          'location'     => '',          'number'       =>'-1',          'orderby'      => 'post_date'        ), $atts));       $page = (get_query_var('paged')) ? get_query_var('paged') : 1;          $output ='
' ;             global $post;         $args = array(         'posts_per_page' => $number,          'orderby' => $orderby,         'paged' => $paged,         'post_type' => 'accomodation',         'tax_query' => array(             'relation' => 'AND',             array(                 'taxonomy' => 'accomodation_category',                 'field' => 'slug',                 'terms' => $accomodation             ),             array(                 'taxonomy' => 'location',                 'field' => 'slug',                 'terms' => $location             )         )     );     $the_query = new WP_Query( $args );               while ( $the_query->have_posts() ) {$the_query->the_post();           $output .=get_template_part( 'loop', 'accomodation' );         };     $output .='
' .get_next_posts_link( __( '← Older posts' ) ) . '
';     $output .= '
' . get_previous_posts_link( __( 'Newer posts →' ) ) . '
';     $output .='
' ;                         wp_reset_query();        return $output;          }      add_shortcode('accomodation-catalog', 'accomodation_catalog_shortcode');      and loop-accomodation.php               <div id="post-<?php the_ID(); ?>" class="accomodation-archive">
                 <?php saimaanliikenne_entry_meta(); ?>                 <?php edit_post_link( __( 'Редактировать', 'saimaanliikenne' ), '', '' ); ?>
              <?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>                 <?php the_post_thumbnail( 'preview' );?>             <?php endif; ?>
             <?php if (get_post_meta( $post->ID, 'bbcosta_alt_title', true )!=='')://если есть альтернативное название выводит его,если нет title ?>
             <a href="<?php the_permalink(); ?>" rel="bookmark">             <?php echo get_post_meta( $post->ID, 'bbcosta_alt_title', true ); ?>
                  <?php else : ?>
                 <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?>
             <?php endif;?>
         <?php echo get_post_meta( $post->ID, 'bbcosta_hotel_location', true ); ?><?php echo get_hotel_star(); ?>
               <?php if ((get_post_meta( $post->ID, 'bbcosta_number_person', true )|get_post_meta( $post->ID, 'bbcosta_area', true ))!==''){?>
          <?php if (get_post_meta( $post->ID, 'bbcosta_number_person', true )!==''){?>         <?php echo get_post_meta( $post->ID, 'bbcosta_number_person', true );?>,<?php } ?><?php echo get_post_meta( $post->ID, 'bbcosta_area', true );  ?>
         <?php } ?>         <?php if ((get_post_meta( $post->ID, 'bbcosta_bedrooms', true )|get_post_meta( $post->ID, 'bbcosta_advantage', true ))!==''){?>
          <?php if (get_post_meta( $post->ID, 'bbcosta_bedrooms', true )!==''){?>         <?php echo get_post_meta( $post->ID, 'bbcosta_bedrooms', true );?>,<?php } ?><?php echo get_post_meta( $post->ID, 'bbcosta_advantage', true );  ?>
         <?php } ?>               <?php if (get_post_meta( $post->ID, 'bbcosta_alt_description', true )!==''){?>
         <?php echo get_post_meta( $post->ID, 'bbcosta_alt_description', true ); ?>
         <?php } ?>         <?php if (get_post_meta( $post->ID, 'bbcosta_price', true )!==''){?>
         <?php if (get_post_meta( $post->ID, 'bbcosta_old_price', true )!==''){?>                  <?php echo get_post_meta( $post->ID, 'bbcosta_old_price', true ); ?> / <?php } ?>         <?php echo get_post_meta( $post->ID, 'bbcosta_price', true ); ?>
 <?php } ?>


Custom Post Type Pagination 404 Error (if paged>=2)

I coded a WordPress theme. I added a Photo Gallery with custom post type. But if `paged>=2`, it gives 404 error. If you open my web site link and click Tümünü Göster (Show All) button, you can test it. Codes: functions.php               add_action( 'init', 'register_cpt_fotograf' );      function register_cpt_fotograf() {      $labels = array(      'name' => _x( 'Fotoğraflar', 'fotograf' ),      'singular_name' => _x( 'Fotoğraf', 'fotograf' ),      'add_new' => _x( 'Yeni Ekle', 'fotograf' ),      'add_new_item' => _x( 'Yeni Fotoğraf Ekle', 'fotograf' ),      'edit_item' => _x( 'Fotoğrafı Düzenle', 'fotograf' ),      'new_item' => _x( 'Yeni Fotoğraf', 'fotograf' ),      'view_item' => _x( 'Fotoğrafı Önizle', 'fotograf' ),      'search_items' => _x( 'Fotoğraf Ara', 'fotograf' ),      'not_found' => _x( 'Fotoğraf Bulunamadı', 'fotograf' ),      'not_found_in_trash' => _x( 'Çöpte Fotoğraf Bulunamadı', 'fotograf' ),      'parent_item_colon' => _x( 'Ana Fotoğraf:', 'fotograf' ),      'menu_name' => _x( 'Fotoğraflar', 'fotograf' ),      );      $args = array(      'labels' => $labels,      'hierarchical' => false,      'supports' => array( 'title', 'author', 'thumbnail', 'custom-fields', 'comments' ),     'public' => true,      'show_ui' => true,      'show_in_menu' => true,      'show_in_nav_menus' => false,      'publicly_queryable' => true,      'exclude_from_search' => false,      'has_archive' => true,      'query_var' => true,      'can_export' => true,      'rewrite' => array('slug' => 'fotograflar'),     'capability_type' => 'post'      );      register_post_type( 'fotograf', $args );      }     function mySearchFilter_0987($query) {      $post_type = $_GET['post_type'];      if (!$post_type) {      $post_type = 'any';      }      if ($query->is_search) {      $query->set('post_type', $post_type);      };      return $query;      };      add_filter('pre_get_posts','mySearchFilter_0987');      archive-fotograf.php               <?php get_header(); ?>     <?php $aranan= $_GET['s']; ?>
     <?php      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array( 'post_type' => 'fotograf' , 's' => $aranan, 'posts_per_page' => 1, 'paged' => $paged );      query_posts($args);     if (have_posts()) : $rakam=0; ?>

Fotoğraf Galerisi      <form action="<?php echo get_bloginfo('wpurl'); ?>" id="searchform" method="get" name="searchform">     <input name="s" id="s" type="text" value=""/>     <input type="hidden" name="post_type" value="fotograf" />      <input id="searchsubmit" type="submit" value="Ara"/>     </form>

<?php while( have_posts() ) : the_post(); $rakam++; ?>     <div class="FGaleriItem2" style="<?php if ($rakam % 5 == 0 ) { ?>margin-right: 0px;<?php } ?>">
<?php if (has_post_thumbnail()) { ?><a href="<?php the_permalink() ?>"><?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );$url2 = get_bloginfo('template_directory') . "/timthumb.php?src=" . $url . "&w=100&h=100&zc=1"; ?><img src="<?php if(get_option('of_timthumb')=="true") { echo $url2; } else { echo $url; } ?>" alt="" title="" width="100" height="100" /><?php } ?>

<a href="<?php the_permalink() ?>"><?php the_title(); ?>

<?php if (($rakam % 5 == 0) && ($rakam > 4)) { ?>

<?php } ?><?php endwhile; ?>

<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?><?php next_posts_link('« Daha Eski Fotoğraflar') ?><?php previous_posts_link('Daha Yeni Fotoğraflar»') ?><?php } ?>
     <?php else : ?>
Yazı bulunamadı.
<?php endif; ?>
<?php wp_reset_query(); ?><?php get_sidebar(); ?>
<?php get_footer(); ?>


Pagination isn't working with search results

I'm having the following problem. Here is a search result page `http://178.62.147.125/?s=142` with pagination (specific with the wp- pagenavi). When I click in the 2nd page it shows 404 page. On everything else on the site (custom taxonomies and normal categories) it works flawlessly. Here is the code of the search.php. I've followed all the instructions to make it work with custom query, i flushed permalinks, I saw that when I click on page 2 the link becomes `http://178.62.147.125/page/2/?s=142`, and I tried to play with that link and change it to `?s=142/page/2` but nothing. What am I doing wrong? Thanks!               <?php get_header(); ?>

                      <?php                          $pat = "#/\?s=(\d+).*#";                     $url = $_SERVER['REQUEST_URI'];                          preg_match($pat, $url, $matches);                          $id = -1;                          if (count($matches) == 2) {                         $id = $matches[1];                     }                          global $wpdb;                          $results = $wpdb->get_results (                         $wpdb->prepare(                             'SELECT * FROM fama_postmeta WHERE meta_key="products_of_recipe" AND meta_value LIKE %s',                             '%"' . $id . '"%'                         )                     );                          $id_array = array(-1);                          foreach ($results as $r) {                              $id_array[] = $r->post_id;                     }                          $search_query = new WP_query(array('post__in' => $id_array, 'post_type' => 'recipes_post_types', 'showposts' => 3, 'paged' => get_query_var('paged')));                          $product = get_post($id);                          ?>

Συνταγές με: <?php echo esc_html( $product->post_title ); ?>

ΟΛΕΣ

                          <?php while( $search_query -> have_posts() ): $search_query -> the_post(); ?>                                 <?php                 $image_id = get_field('recipe_photo');                 $image_size = 'recipe-thumb';                 $image_array = wp_get_attachment_image_src($image_id, $image_size);                 $image_url = $image_array[0];                 ?>

                         <img src="<?php echo $image_url; ?>" alt="">

<a href="<?php echo get_permalink(); ?>"><?php echo get_the_title(); ?>

<?php the_field('recipe_info'); ?>

                 <?php endwhile; ?>                 <?php wp_reset_postdata(); ?>

                     <?php if(function_exists('wp_pagenavi')) {                      wp_pagenavi( array(                      'query' => $search_query                      ));                     }                ?>

     <?php get_footer(); ?>


Pagination custom category page template

I want to display product categories on separated pages. Should be 6 posts of 1 category on a page, and if we have more than 6 postings in this category, - so I want to display a pagination. I googled hours, tried a lot, but nothing was working. I used the blank theme "base" from themify. The only thing I got to work is this:               <?php     global $wp_query;     $result = new WP_Query('cat=5');     $args_pagi = array(     'base' => add_query_arg( 'paged', '%#%' ),     'total' => $result->max_num_pages,     'current' => max( 1, get_query_var('paged') )     );          $args = array(             'orderby'        => 'post_date',             'order'            => 'DESC',             'category'        => '5',             'post_type'        => 'post',             'post_status'        => 'publish',             'posts_per_page'    => 6,             'paged'            => $paged,         );          $myposts = new WP_Query( $args );     foreach( $myposts->posts as $post ) : setup_postdata($post); ?>

<a href="<?php the_permalink() ?>"><?php the_title(); ?>

              <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array( 120,120 ), array( 'class' => 'recent-thumbs' )); ?>              <?php the_excerpt(); ?>
     <?php endforeach; ?>
     <?php echo paginate_links( $args_pagi);?>
       The problem is, the output was mixed by categories, - shows 5 posts of cat.`5` and 1 of cat.`7`, shows four products of cat.`7` on page 2 and two of cat.`5`. (there are 8 postings of cat.`5` in db) Under `/wp-admin` "Reading", the setting is 6 posts per page. What is wrong?


Wordpress Page-Navi custom page error 404

I installed the WP-PageNavi plugin on my site. Then I added a new custom page with WP-PageNavi. mysite/page/1/ - working mysite/page/2/ - working mysite/page/3/ - error 404 not found mysite/page/4/ - error 404 not found ....                 $temp = $wp_query;       $wp_query= null;       $wp_query = new WP_Query();       $wp_query->query('post_type=post&showposts=4&paged='.$paged);            $count=1;           if (have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post();             // content show post          endwhile;          endif;         wp_pagenavi();          wp_reset_query();      Why does it stop working on page 3, page 4 but it still working with page 1 and 2 ?


Pagination not working with custom loop

I've got a custom loop that I'm using to display some Real Estate listings that will be available within 60 days. I'm calling it with the following function:               <?php      $sixtydays = date('Y/m/d', strtotime('+60 days'));     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $query = new PostsOrderedByMetaQuery(array(       'post_type' => array('post', 'real-estate'),       'meta_key' => 'Time Available',       'meta_compare' => '<=',       'meta_value' => $sixtydays,       'paged' => $paged,       'orderby_meta_key' => 'Price',       'orderby_order'    => 'ASC'     ));     ?>     <?php while ($query->have_posts()) : $query->the_post(); ?>      While the loop works great, I can't get it to paginate. It shows the first 10 (my default) posts but doesn't show the pagination. The only way to display all posts is to show them on one page by adding `'posts_per_page' => -1,` I have similar loops on other pages that have no problem paginating. The only difference with this one is that there are **two** meta keys that are filtering the posts. I'm using WP Page Navi for this and the rest of my pages. I'm closing the loop and adding the pagination using the following code:               <?php endwhile; // End the loop. Whew. ?>     <?php wp_pagenavi(); ?>     <?php wp_reset_query(); ?>      How can I go about fixing this?


Pagination for Custom Taxonomy Page

I'm having an issue getting my custom taxonomy page to paginate correctly. I looked through other examples posted on this forum, but I could not get my second page to not return a 404 error page. Here are my details   * **Custom Tax:** Study_Tags   * **Example Terms:** Community, Economy, Crime...   * **Custom Taxonomy Page:** taxonomy-study_tags.php   * **Posts Per Page:** 5 _(set in Reading Settings, global for all pages/posts on site)_ I am using a Custom Post Type "Study" with the custom taxonomy "Study Tags", which is why i feel I need to use the "query_posts()" function. I only want to show parent pages in the results, as each "Study" CPT can have children page with study details, presentations... etc. My information to setup the query               <?php         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $args = array_merge( $wp_query->query_vars,          array(                 'post_type'=> 'study',                 'post_parent' => '0',                 'paged' => $paged,                 'order' => 'ASC',                 ));                 query_posts($args);          ?>      $wp_query->query_vars passes for example "[study_tags] => community" when var_dump() is used, so I know it is transmitting the correct term to the custom tax page. Any ideas how to get a second page of results?


Unable to get paginate_links working with a custom query

I have built a news section in my Wordpress site with the advanced custom fields and custom post type ui plugins. On the custom news overview page (not the standard wordpress posts) I wanted to limit the number of news per page to six and provide a navigation with paginate_links. I've built the following snippet:
         <?php             $args = array(                 'post_type' => 'news',                 'posts_per_page' => '6'             );             $the_query = new WP_Query( $args );             $temp_query = $wp_query;             $wp_query = NULL;             $wp_query = $the_query;             $pagination = array(                 'base' => '%_%',                 'format' => '?page=%#%',                 'total' => $the_query->max_num_pages,                 'prev_next' => True,                 'prev_text' => __( '<< Previous' ),                 'next_text' => __( 'Next >>' )             );             if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

<?php the_time( 'j. F Y' ); ?>
                     <a href="<?php the_permalink(); ?>">
<?php the_title(); ?>

<?php echo acf_excerpt( 'news_post', 35, ' [...]' ); ?>

<a href="<?php the_permalink(); ?>">More →

         <?php endwhile; ?>             <?php wp_reset_postdata(); ?>         <?php else: ?>
No entries
         <?php endif; ?>                      <?php echo paginate_links( $pagination );                     $wp_query = NULL;                     $wp_query = $temp_query; ?>
      First the arguments for the wp_query are defined, then `$the_query` is set with a WP_Query afterwards the `$wp_query` variable is saved into a temporary variable, reset with NULL and then set to the `$the_query` variable. In the last step the settings array for the `paginate_links` is set. Then there is the loop for outputting news posts. After the loop the paginate_links function is called and finally the `$wp_query` got reset and written back the content of the temporary `$temp_query` variable. If I have let's say 15 blog posts my output looks like the following: ![paginate_links layout](http://i.stack.imgur.com/hgTBu.png) If I hover over the number three, the end of the slug looks like the following: ![slug for page 3](http://i.stack.imgur.com/i4jqq.png) Problem is now the previous and next links are not shown even that they are set. While the main problem is the given slug - if I click the number three I land on a 404 page. "page 3" where I get directed to is unknown for wordpress. Thanks in advance Ralf **Update:**               $args = array(         'post_type' => 'news',         'posts_per_page' => '1'     );       $the_query = new WP_Query( $args );     $temp_query = $wp_query;     $wp_query = NULL;     $wp_query = $the_query;     $total_pages = $wp_query->max_num_pages;     if ( $total_pages > 1) {         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $current_page = new WP_Query('post_type=news&posts_per_page=1&paged=' . $paged);         $pagination = array(             'base' => '%_%',             'format' => '?paged=%#%',             'mid-size' => 1,             'current' => $current_page,             'total' => $total_pages,             'prev_next' => True,             'prev_text' => __( '<< Previous' ),             'next_text' => __( 'Next >>' )         );     }      Update 2: Ok with the following changes to the first part of the code i got the nav working               $args = array(         'post_type' => 'news',         'posts_per_page' => '3',         'paged' => get_query_var( 'paged' )     );       $the_query = new WP_Query( $args );     $temp_query = $wp_query;     $wp_query = NULL;     $wp_query = $the_query;     $total_pages = $wp_query->max_num_pages;     if ( $total_pages > 1) {         $the_paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $pagination = array(             'base' => @add_query_arg('paged','%#%'),             'format' => '?paged=%#%',             'mid-size' => 1,             'current' => $the_paged,             'total' => $total_pages,             'prev_next' => True,             'prev_text' => __( '<< Previous' ),             'next_text' => __( 'Next >>' )         );     }      The only question i have left (the only thing which is still misbehaving) is it possible that the first link has link instead of link/?paged=1


How to display a paginated list of posts from one category on a page?

I'm trying to use the code from this page: Display Blog Posts on any Page (with navigation) http://digwp.com/2013/01/display-blog-posts-on-page-with-navigation/ My goal is to make pages that display the posts from one category only. I'd also like to limit the number of posts per page to 5 and have pagination links at the bottom. This will display the first 5 posts form all categories and paginate them:               <?php // Display blog posts on any page @ http://m0n.co/l     $temp = $wp_query; $wp_query= null;     $wp_query = new WP_Query(); $wp_query->query('showposts=5' . '&paged='.$paged);     while ($wp_query->have_posts()) : $wp_query->the_post(); ?>       However when I try to add the category in like this:               <?php // Display blog posts on any page @ http://m0n.co/l     $temp = $wp_query; $wp_query= null;     $wp_query = new WP_Query(); $wp_query->query('cat=61' , 'showposts=5' . '&paged='.    $paged);     while ($wp_query->have_posts()) : $wp_query->the_post(); ?>      I get more than 5 posts on my page and no pagination...


pagination does not work with query_posts. Help!

I made a separate page template (added sidebar), this page contains all the posts. Pagination works! But, if this page set as the home page, pagination is not working! Please help find solutions myself I can not ... This my code This code of my custom posts page This code of my pagination


Pagination problem: query not remembered on page 2, 3,

I read numerous question about pagination here but still couldn't find a way to make mine work. At first, the total number of pages in the pagination element is displayed correctly, and there's one post displayed. However, if I proceed to page 2, there is no post displayed and the pagination element resets to one page in total. It seems that the query isn't remembered when proceeding to page 2. When I go back to page 1 from there, no post is displayed either. Thank you for your help!               <?php     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;          $args = array(           'post_type' => 'custom-post-type',         'posts_per_page' => 1,         'paged' => $paged     );       $the_query = new WP_Query( $args );     ?>
                              <?php if ( have_posts() ) : ?>                <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>                   <?php get_template_part( 'content'); ?>                    <?php endwhile; ?>                <?php endif; ?>

                                                                       <?php wp_pagenavi(array( 'query' => $the_query ) );    ?>
     <?php wp_reset_postdata(); ?>


Pagination wont work with search results template

I can't seem to get pagination to work correctly in my search results template. The page links appear, but when i click onto page 2, it gives me a 404 error. **Search.php**               <?php     global $wp_query;     $total_results = $wp_query->found_posts;     ?>          <?php     if(!$wp_query) global $wp_query;     $search_refer = $_GET["post_type"];     if ($search_refer == 'archive') { load_template(TEMPLATEPATH . '/search-gallery.php');}     else{load_template(TEMPLATEPATH . '/search-standard.php');}     ?>      **Pagination Code in Functions.php**               function pagination($pages = '', $range = 4){        $showitems = ($range * 2)+1;             global $paged;      if(empty($paged)) $paged = 1;           if($pages == '')      {          global $wp_query;          $pages = $wp_query->max_num_pages;          if(!$pages)          {              $pages = 1;          }      }              if(1 != $pages)      {          echo "
Page ".$paged." of ".$pages."";          if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "« First";          if($paged > 1 && $showitems < $pages) echo "‹ Previous";               for ($i=1; $i <= $pages; $i++)          {              if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))              {                  echo ($paged == $i)? "".$i."":"".$i."";              }          }               if ($paged < $pages && $showitems < $pages) echo "Next ›";            if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "Last »";          echo "
\n";      }     }      **Search Results Template**                   <?php         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $search_query = array(             'posts_per_page' => '10',             'paged' => $paged,             );         $wp_query = new WP_Query($search_query);              if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

                     <?php the_post_thumbnail(); ?>

<?php the_title();?>

                     <?php the_excerpt(); ?>

             <a title="Student Awards" href="<?php the_permalink();?>">Read More
<?php edit_post_link('Edit'); ?>     <?php endwhile; ?><?php else : ?>
Sorry, nothing came back matching what you searched. Try again?
     <?php endif; ?>               <?php pagination(); ?>      Any suggestions?


How do I create pagination?

I've got a site with a static front page and another page for posts. On the posts page I'm using paginate_links() to generate pagination. However, it isn't producing output. Dumping the output as a variable returns NULL. Here is the code I have currently: http://hastebin.com/teqohecura.xml What am I doing wrong here? How do I get pagination?


pagination /page/2 redirects to home page (domain.com)

Either using wp-pagenavi or the standard wp pagination (posts_nav_link()) a click to mydomain.com/page/2 will result in a 301 redirect back to the home page (url = domain.com ) This is not a duplicate, the other post talks nothing about redirects. Also, my wp_query seems fine, as it works with pretty permalinks off. Also, this whole thing works on at least one site with identical plugins and theme, etc. UPDATE: http://domain.com/category/validCategory/page/2/ does work... turning off pretty permalinks and using ?page=2 works. Yes, I am using               $args['paged'] = get_query_var( 'page' );     $wp_query = new WP_Query( $args );     $posts = $wp_query->posts;      to modify the posts. if I make it               $args['paged'] = 2;      It will show the second page of posts, but on the home page. Yes, I have read several articles about not using a new query, but have determined that it is better for me if I do. However, this redirection is happening before it ever gets to this, afaik. I'm sticking a die() in there but it doesnt die until it's redirected, and dies on the home page. Nothing in my htaccess would do this               php_value max_execution_time 3600     #php_flag display_errors on     #php_value error_reporting 7     php_value upload_max_filesize 20M     php_value post_max_size 20M          RewriteCond %{HTTP_HOST} ^www.domain.com     RewriteRule (.*) http://domain.com/$1 [R=301,L]               RewriteRule ^wp-content/uploads/(.*) /uploads/$1 [QSA,L]          # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress      This is a new problem, only occuring on a couple of sites out of many that are running on identical installs. I dont see any differences between working and non working. So, if no one has the easy answer, where do I start to debug and find out where wp is deciding it needs to redirect to home?


Pagination paginate_links() Not Working

Here's my code               <?php                                  query_posts(array('category_name'=>'nutrition','posts_per_page'=>'3','paged' => get_query_var('paged')));                             while (have_posts()) : the_post();?>

                                 <?php if ( has_post_thumbnail() ) {                                       the_post_thumbnail(  array(90,90,)); } ?>

                                 <a class="semibold title" href="<?php the_permalink();?>" title="<?php the_title();?>"><?php the_title();?>
Posted By: <?php the_author(); ?>
                                 <?php the_excerpt();?>

                                  <?php endwhile; wp_reset_query( );?>                             <?php echo paginate_links( $args ) ?>     <?php     global $wp_query;          $big = 999999999; // need an unlikely integer          echo paginate_links( array(         'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),         'format' => '?paged=%#%',         'current' => max( 1, get_query_var('paged') ),         'total' => $wp_query->max_num_pages     ) );     ?>      The problem is, its not even working, What's wrong with my code? Here's the page


how to add pagination and post query in taxonomy-taxonomy-term.php?

I am have a theme by the "blog" post type and I use the code below to add term category to this post type               $labels = array(             'name'                                            => 'دسته‌ها',             'singular_name'                          => 'دسته‌ها',             'search_items'                            => 'جستجوی دسته',             'popular_items'                          => 'بیشتر استفاده شده',             'all_items'                                      => 'تمام دسته‌ها',             'parent_item'                              => 'مادر دسته',             'edit_item'                                      => 'ویرایش دسته',             'update_item'                              => 'بروزرسانی دسته',             'add_new_item'                            => 'افزودن دسته جدید',             'new_item_name'                          => 'دسته جدید',             'separate_items_with_commas'    => 'جداسازی دسته‌ها با کاما',             'add_or_remove_items'              => 'افزودن یا حذف دسته',             'choose_from_most_used'          => 'انتخاب از محبوبها'             );     $args = array(       'label'                                                => 'دسته',       'labels'                                              => $labels,       'public'                                              => true,       'hierarchical'                                  => true,       'show_ui'                                        => true,       'show_in_nav_menus'                    => true,       'args'                                                  => array( 'orderby' => 'term_order' ),       'rewrite'                                        => array( 'slug' => 'term', 'with_front' => true ),       'query_var'                                    => true     );     register_taxonomy( 'term', 'blog', $args );      I don't know what query can see the posts and I need to know how to add pagination to this file. My `taxonomy-term.php`:               <?php get_header(''); ?>

         <hgroup>
وبلاگ روکش

 آخرین اخبار و رویداد های روکش را در وبلاگ روکش دنبال کنید و از تکنولوژی ها و آموزش های روکش در حهت افزایش آگاهی و مهارت های خود در زمینه طراحی وب استفاده کنید.

         </hgroup>

     <?php if ( function_exists('yoast_breadcrumb') ) {     yoast_breadcrumb('

','

');     } ?>

     <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query();     if(!empty($wp->query_vars['term'])){ $terms = $wp->query_vars['term']; $taxonomy = 'term'; }     if(!empty($wp->query_vars['library-tags'])){ $terms = $wp->query_vars['library-tags']; $taxonomy = 'library-tags'; }     $paged = ($wp->query_vars['page']) ? $wp->query_vars['page'] : 1;     $args = array(       'post_type' => 'blog',       'paged' => $paged,       'tax_query' => array(        array(                     'taxonomy' => $taxonomy,                     'field' => 'slug',                     'terms' => $terms        )       )     );     $wp_query->query( $args ); ?>     <?php if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post(); ?>              <div class="news" id="<?php the_ID();?>">                                  <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                     <img alt="<?php the_title(); ?>" title="<?php the_title(); ?>" src="" />
                                                       <?php echo get_the_term_list( $post->ID, 'term',  ' ', '' ); ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>

                                                                       <?php the_author_posts_link();?>                                                                                <?php the_date('d F y') ;?>

                 <?php the_content("ادامه مطلب ..."); ?>

          <?PHP endwhile; endif; ?>     <?php paginate(); ?>     <?php $wp_query = null; $wp_query = $temp;?>

خبرنامه روکش
             <form>                 <input type="text" placeholder="ایمیل خود را وارد کنید"/>                 <input type="submit" value="ثبت"/>             </form>

دسته بندی ها
             <?php             $args = array('container' => false, 'theme_location' => 'blog');             wp_nav_menu($args);     ?>

                 <?php get_footer(); ?>                 <?php wp_footer(); ?>


paged query leads to 404?

As soon as I click the "2" on my pagination links I get a 404-error. The url correctly changes to `http://mysite.com/?paged=2`               <?php     /**      * The loop that displays the posts.      */     ?>
     <?php              $args = array(             'post_type' => array('post', 'wr_raffle'),             'posts_per_page' => 4,             'order' => 'DESC',             'paged' => (get_query_var('page')) ? get_query_var('page') : 1,         );              $loop = new WP_Query( $args );         while ( $loop->have_posts() ) : $loop->the_post(); ?>
             <article id="post-<?php the_ID(); ?>" <?php post_class('wrapper'); ?>>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

<?php the_excerpt(); ?>

                  <?php endif; ?>              <?php          endwhile;         wp_reset_postdata();          ?>

     <?php         $endsize = $midsize = 1;         $type = 'plain';         $loop->query_vars['paged'] > 1 ? $current = $loop->query_vars['paged'] : $current = 1;              // Sanitize input argument values         if ( ! in_array( $type, array( 'plain', 'list', 'array' ) ) ) $type = 'plain';         $endsize = (int) $endsize;         $midsize = (int) $midsize;              // Setup argument array for paginate_links()         $pagination = array(             //'base'          => @add_query_arg('paged','%#%'),             'total'         => $loop->max_num_pages,             'current'       => $current,             'show_all'      => false,             'end_size'      => $endsize,             'mid_size'      => $midsize,             'type'          => $type,             'prev_next'     => false,             //'paged'         => $loop->query_vars['paged']         );              echo paginate_links( $pagination );     ?>
      What am I doing wrong here? I already refreshed my permalinks. Didn't work.


Adding pagination to WP_Query

I've got the following loop (this is on a `single` page, not the `index.php`):               $top_meta_cat_args =         array(         'posts_per_page' => 9,         'post_type' => 'post',         'meta_key' => 'top-radio',         'meta_value' => 'top-yes',         'post_status' => 'publish',         'orderby' => 'date',         'order' => 'DESC'     );      And it works perfectly. However, when I add code to take the user to the next page, nothing happens:               <a href="<?php echo get_next_posts_page_link();  ?>" class="btn-ar"> more articles      This adds to the current URL: `&paged=3`, but the content is still the same. I've also tried removing the `echo`, but nothing happens. The Codex explains about adding pagination. But I am unsure how to use this with the associative array that I exampled above. Any help would be great.


WP-Paginate giving "Page not found" error on page 2

I have pagination showing for my second page, but when I click it I get a "page not found" page instead. The url is utcommons.com and the code for the index file can be seen at http://pastebin.com/rkA040ZJ.


paginate_links with meta_query showing incorrect number of pages

I seem to be having a strange problem with paginate_links, and I'm hoping someone can help. I have a custom post type for events, events have categories and a custom field for start date and end date. Using paginate_links(), pagination is output correctly and works fine when showing the archive. When filtering by category, the pagination is also correct. The problem is when I try to do a meta query on the end date, the results I get are as expected, but paginate_links is outputting the total number of pages needed to show all of the events, instead of just the events returned from the query. Here is the query:               $args = array(         'post_type' => 'events',         'orderby' => 'meta_value',         'meta_key' => 'start_date',         'order' => 'ASC',         'paged' => get_query_var('paged'),         'meta_query' => array(             array(                 'key' => 'end_date',                 'value' => 20130525,                 'compare' => '>='             )         )     );     $query = new WP_Query($args);      and this is my pagination:               global $wp_query;     global $paged;     $big = 999999999; // need an unlikely integer          echo paginate_links(array(         'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) )),         'format' => '?paged=%#%',         'current' => max( 1, get_query_var('paged') ),         'total' => $wp_query->max_num_pages,         'prev_next' => false,         'type' => 'list'     ));      Am I doing something obviously wrong that could be causing this? It's been a major headache for a few days now.


Pagination in custom loop

I thought I know how to add pagination to a custom loop and I've seen these questions and tutorials:   * Pagination not working with custom loop   * http://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops/   * http://www.wplover.com/756/how-to-get-custom-wp_query-loop-working-with-pagination-and-wp-pagenavi/ but for some reason it doesn't work at this time. I created myfile.php, named it to "My Page Template" and set that to be my front page in Admin Panel > Settings > Reading.               $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;          $args = array(         'post_type' => array('my_custom_post_type'),         'paged' => $paged,         'posts_per_page' => 3,         'ignore_sticky_posts' => 1     );          $wp_query = new WP_Query( $args );     var_dump($wp_query);     if($wp_query->have_posts()) :         while($wp_query->have_posts()) : $wp_query->the_post();             // show post         endwhile;     endif;          next_posts_link('Next posts');          wp_reset_query();     wp_reset_postdata();      What happens:   * Front page shows 3 posts as expected.   * "Next posts" link is shown and points to http://example.com/page/2/ as expected.   * While I'm on http://example.com/page/2/ it shows the same set of posts and "Next posts" link points to http://example.com/page/2/ which is not what I want.   * `var_dump($wp_query)` shows `public 'max_num_pages' => float 8`.   * `var_dump($wp_query)` shows `public 'found_posts' => string '24' (length=2)`.   * `var_dump($wp_query)` shows `public 'is_paged' => boolean false`.   * `var_dump($wp_query)` shows `'paged' => int 1` (when I'm on page number 2).   * When I'm renaming `$wp_query` to `$my_custom_query` then "Next posts" link doesn't show at all. Is there anything else I should do here? UPDATE: I managed to set proper `$paged` by changing `$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;` to `$paged = (get_query_var('page')) ? get_query_var('page') : 1;` but it still shows a wrong navigation link.


How to add pagination to wp_query

I have a custom loop and I'm trying to break it up into several pages but I'm not getting the next and previous links to show. Here is my code:                               <?php                              if ( get_query_var( 'paged' ) )                             // On a paged page.                             $paged = get_query_var( 'paged' );                              else if ( get_query_var( 'page' ) )                             // On a "static" page.                             $paged = get_query_var( 'page' );                              else                             // Default.                             $paged = 1;                              $args = array(                             'post_type'      => 'property',                             'orderby'        => 'meta_value',                             'meta_key'       => 'random_775',                             'order'          => 'ASC',                             'paged'          => $paged,                             'posts_per_page' => 10,                         );                     ?>                          <?php $count = 0;                              $loop = new WP_Query( $args );                         while ( $loop->have_posts() ) : $loop->the_post(); ?>                                  <?php next_posts_link('Next' ); ?>                             <?php previous_posts_link('Back' ); ?>      I'm not sure what I'm doing wrong or is someone can shed some light on it. Thanks in advance!


Custom Pagination for a Page with Comments

> **Possible Duplicate:**   >  Pagination not working with custom loop Hello everybody and good even. The Problem: I have a Page where the comments are listed like the posts a displayd in a category and now my problem is, that I am not well versed in the field of custom Pagination for a custom query for wordpress.               $comments = (isset($_GET['adv_comments']) == 'on') ? true : false; if ($comments) {     function adv_comment_search(){              global $wpdb;         global $data;         $count = $data['adv_number_comments'];              $commenters = array();              $results = $wpdb->get_results("SELECT comment_content, comment_date, comment_ID, user_id, comment_author, comment_author_url, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1'");              foreach($results as $result){             if(strpos(strtolower($result->comment_content), strtolower(get_search_query())) !== false){                 $commenters[] = (array) $result;             }         }              $thetimearr = array();         foreach ($commenters as $key => $row){             $thetimearr[$key] = $row['comment_date'];         }              array_multisort($thetimearr, SORT_DESC, $commenters);                        $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;              $current_page = $paged;         $total_pages =-1;              $start = ($paged - 1) * $count;         $end = $paged * $count;                        if ($end > count($commenters)) $end = count($commenters);                   $output = '
';         if(count($commenters) != 0) {             $output .= 'Comments results for: '.get_search_query().'';         }else{             $output .= 'No comment results!';         }         $cc = 1;         if ($paged > 1) $cc = ($count * $paged) - ($count -1);              for ($i = $start; $i < $end; $i++){                          $comment = $commenters[$i];                     $permalink = get_permalink( $comment['comment_post_ID'] );                     $output .= '
';                     $output .= '
'.$cc.'
';                     $output .= '
';                     $output .= '
';                     $output .= '            '.$comment['comment_author'].'';                     $output .= '
'.time_ago($comment['comment_date']).'
';                     $output .= '
';                     $output .= '
';                                         $output .= '
'.$comment['comment_content'].'
';                     $output .= '
';                     $output .= '
';                     $output .= '
';                          $cc++;         }                   $output .= '
';              echo $output;          return array(             'current_page' => $current_page,             'total_pages' => $total_pages         );     }      How can i add a pagination?