Support » Fixing WordPress » wp query pagination always redirecting to index.php

  • louissoriano

    (@louissoriano)


    Hi, I am new to this forum and hoping if you guys can help me. I have a category page, and inserted a wp_query loop which calls for the specific category and inserted the next_post_link to show page 2 of the category post. I have searched a lot of forums and tested a lot of codes but it keeps redirecting me to index.php. Do I need to create a function.php or modify htaccess? Sorry I’m really new to wordpress as I think this is working before I upgraded to version 3 of wordpress. Below is my code

    <?php
    
    							$wp_query = new WP_Query();
    
    							$wp_query->query('category_name=nail-salon&showposts=1&order=ASC'.'&paged='.$paged);
    						?>
    
                            <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    
                            <?php the_content(); ?>
    
                           		<div style="clear:right;"></div>
    
                            	<br /><br />
    
      							<div class="float-right" style="margin-left:10px;"><p><?php next_posts_link('More &raquo;') ?></p></div>
                                <div class="float-right"><p><?php previous_posts_link('&laquo; Previous') ?></p></div>
    
                            <?php endwhile;?>
Viewing 7 replies - 1 through 7 (of 7 total)
  • louissoriano

    (@louissoriano)

    I am not sure if I should insert some code in my index.php to fix this because I am not using my index page in any of my template in wordpress. Thank you for your help as I am stuck with this problem for 3 days now. Cheers.

    spencerfinnell

    (@spencerfinnell)

    Does it actually redirect back to index.php, (in the address bar) or is it just not showing the next page of posts?

    louissoriano

    (@louissoriano)

    Oh, actually the category link is in this page
    http://www.avalonsalondayspa.com/category/nail-salon/

    and when I click what’s supposed to be the next link (more link), it rediretcs to index.php

    http://www.avalonsalondayspa.com/category/nail-salon/page/2/

    Thank you for your reply.

    louissoriano

    (@louissoriano)

    To follow up, it actually redirects to index.php template file, which it shouldn’t.

    louissoriano

    (@louissoriano)

    Actually is it possible to direct the “more” link from this page

    http://www.avalonsalondayspa.com/category/nail-salon/

    which is category-8.php instead of directing it to index.php template?

    louissoriano

    (@louissoriano)

    I was able to fix the problem temporarily by modifying the admin in Reading to Blog pages show at most = 1. But I know it’s possible just to use query by indicating in how many category posts to show. Please let me know for more solutions on this problem. Thanks

    I also faced the same problem as you!

    Thanks for the fix! I changed Reading -> Blog pages to 1 like what you have suggested.

    For indicating the number of category posts shown per page, you can try using posts_per_page in your Query… 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘wp query pagination always redirecting to index.php’ is closed to new replies.