WordPress.org

Ready to get started?Download WordPress

Forums

wp query pagination always redirecting to index.php (8 posts)

  1. louissoriano
    Member
    Posted 4 years ago #

    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;?>
  2. louissoriano
    Member
    Posted 4 years ago #

    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.

  3. Spencer Finnell
    Member
    Posted 4 years ago #

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

  4. louissoriano
    Member
    Posted 4 years ago #

    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.

  5. louissoriano
    Member
    Posted 4 years ago #

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

  6. louissoriano
    Member
    Posted 4 years ago #

    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?

  7. louissoriano
    Member
    Posted 4 years ago #

    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

  8. xbfish
    Member
    Posted 3 years ago #

    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... :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags