Quantcast
Viewing all articles
Browse latest Browse all 31591

victorfliks on "Pagination Error 404 on specific page"

Hello,

I'm a beginer wordpress developer, i've been using wordpress since 2 month ago, and im having difficulty on pagination... i'm using custom template and all the post generated using query_post on my page i used 3 query_posts to generate different content on 1 page...

my problem is, on this page, i want some pagination but i always ended up on 404 when im on the fourth page (not second or third page).. i will show u my code, i also put the total post on each query_post that i used..

my first query_posts

<?php
				$args = array(
						'post_type' => 'slide',
						'order' => 'ASC'
						);
				query_posts($args);
				if(have_posts()) : while(have_posts()) : the_post();
			?>
			<li>
				<?php the_post_thumbnail(); ?>
			</li>
			<?php
				endwhile; endif;
				wp_reset_query();

				// OUTPUT 4 POST
			?>

my second query_posts

<?php
					$args = array(
							'post_type' => 'home',
							'meta_query' => array(
									array(
											'key' => 'type',
											'value' => 'Main Title Home'  //im using CUSTOM POST TYPE ON THIS ONE...
									)
							)
						);
					query_posts($args);
					if(have_posts()) : the_post();
				?>
            	<h1 class="blue"><?php the_title(); ?></h1>
				<?php the_content(); ?>
				<?php
					endif;
					wp_reset_query();

					// OUTPUT 1 POST
				?>

my third query_post (this one is the post that i want to add pagination)

<?php
					$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

					$args = array(
							'posts_per_page' => 1,
							'category_name' => 'gallery',
							'paged' => get_query_var('paged'),
							'order' => 'DESC'
						);
					query_posts($args);

					if(have_posts()) : while(have_posts()) : the_post();
					?>
					<!-- START LOOP -->
                	<div class="kolom-blog">
                    	<div class="kolom-blog-tanggal">
                        <?php the_time('j'); ?>
                        <span><?php the_time('F'); ?></span>
                        </div>
                    	<div class="kolom-blog-judul">
                        <a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a>
                        </div>
                        <div class="clear"></div>
                        <div class="kolom-blog-gambar">
                        <?php the_post_thumbnail(); ?>
                        </div>
                        <div class="kolom-blog-teks">
						<?php the_excerpt(); ?>
                        </div>
                    </div>
					<?php
						endwhile; endif;
						wp_reset_query();

						// OUTPUT 8 POST
					?>

					<!-- END LOOP -->

and here my pagination function:

<?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,
									'prev_text'    => __('PREVIOUS'),
									'next_text'    => __('NEXT')
								) );

							?>

i've already tried to refresh my permalink structure, set my default post per page to 1 from backend, using next_posts_link() & previous_posts_link() but they always redirect me to 404 when im on the fourth page and so on...

i've also heard that using query_post can damage pagination, are ay other way to safely implement pagination using query_posts??

Thank You Very Much
and sorry for my bad english...


Viewing all articles
Browse latest Browse all 31591

Trending Articles