WordPress.org

Ready to get started?Download WordPress

Forums

Next and Prev links not working (15 posts)

  1. bmabetha
    Member
    Posted 2 years ago #

    Oh ,I want to display 5posts per page, need help with the next & Prev links, they work on localhost but they dont on the hosting server.
    This is how i did it <?php next_posts_link('Next'); ?>
    What should I do?

  2. Xam 1.0
    Member
    Posted 2 years ago #

    Should work. What's the url?

  3. bmabetha
    Member
    Posted 2 years ago #

    Im not sure which url you are looking for, so this is the url to the site that im woking on http://www.harukami.co.za/blog/

    Hey just found out, this links only are working on the home.php page but they dont on the category.php page.

  4. Xam 1.0
    Member
    Posted 2 years ago #

    So did you add the navigation links in category.php?

  5. bmabetha
    Member
    Posted 2 years ago #

    I did, but i ended up removing them!

  6. bmabetha
    Member
    Posted 2 years ago #

    But this is how it should be, Is that so? or should I say this how I want it to be.

    <?php get_header(); ?>
    
     <?php global $query_string; query_posts( $query_string . '&posts_per_page=4'); ?>
    
      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      <div class="post">
       <div class="date"><?php the_time('F dS Y'); ?></div>
         <div class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></div>
     <div class="tags">
     <?php the_tags('Selected works: ', ', ', '<br />'); ?>
    </div>
    
         <div class="entry">
        <?php the_content( '<div id="entry-more">More Information</div>' ); ?>
        <div id="separate">|</div>
        <div id="comm"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></div>
    
       <div id="dividerLine"></div>
    
         </div>
        </div>
         <?php endwhile; ?>
    
    <div id="navigation">
    	 <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
    			else { ?>
                            <div id="prev_link"><?php previous_posts_link('&laquo; Previous') ?></div>
    			<div id="next_link"><?php next_posts_link('Next &raquo;') ?></div>
    			<?php } ?>
    <!-- Page number inattivo
    <?php if(function_exists('wp_page_numbers')) : wp_page_numbers(); endif; ?>
    --></div>
    
    <?php else: ?>
        <h2>Not Found</h2>
        <p>Sorry, but you are looking for something that isn't here.</p>
        <?php endif; ?>
    <?php get_sidebar();?>
    <?php get_footer();?>
  7. Xam 1.0
    Member
    Posted 2 years ago #

    Yes that should work.

  8. bmabetha
    Member
    Posted 2 years ago #

    Thanks,

    Well I dont know what's wrong with it, it only works well on the home.php page but I also need it on the category page.

    There's no plugin that I should install and activate?

  9. bmabetha
    Member
    Posted 2 years ago #

    By the way,

    I also wanted to add categories on my sidebar, look at this link here http://harukami.co.za/blog/

    If you notice there's a heading named Case Studies which displays categories, Other Links to be the same, but display different categories.

    Do you have an idea on how I could do that?

  10. Xam 1.0
    Member
    Posted 2 years ago #

    No for the basic navigation you don't need to activate any plugin. First deactivate any plugins you have activated. The navigation should have classes instead of id's like so

    <div class="navigation">
    	 <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
    			else { ?>
                            <div class="prev_link"><?php previous_posts_link('&laquo; Previous') ?></div>
    			<div class="next_link"><?php next_posts_link('Next &raquo;') ?></div>
    			<?php } ?>
    <!-- Page number inattivo
    <?php if(function_exists('wp_page_numbers')) : wp_page_numbers(); endif; ?>
    --></div>

    and change your css accordingly ,#navigation to .navigation etc.

    See if it works now. If not change the navigation part like this

    <div class="navigation">
                            <div class="prev_link"><?php previous_posts_link('&laquo; Previous') ?></div>
    			<div class="next_link"><?php next_posts_link('Next &raquo;') ?></div>
    </div>
  11. Xam 1.0
    Member
    Posted 2 years ago #

    And for the categories in the sidebar you can use list_categories.
    http://codex.wordpress.org/Template_Tags/wp_list_categories

  12. Aboobacker P
    Member
    Posted 2 years ago #

    Hi bmabetha,
    Instead of this query string <?php global $query_string; query_posts( $query_string . '&posts_per_page=4'); ?> use the following query. It should work.

    <?php
        global $paged;
        if(!$paged) {
            query_posts('showposts=4');
        }else {
            query_posts('showposts=4&paged=' . $paged);
        }
    ?>
  13. Xam 1.0
    Member
    Posted 2 years ago #

    Or just delete the query

    <?php global $query_string; query_posts( $query_string . '&posts_per_page=4'); ?>

    and go dashboard > settings > reading and set Blog pages show at most to 5.

    That should fix it.

  14. bmabetha
    Member
    Posted 2 years ago #

    Hey, Thanks a lot, if finally works, this is how is did id

    Or just delete the query

    <?php global $query_string; query_posts( $query_string . '&posts_per_page=4'); ?>

    and go dashboard > settings > reading and set Blog pages show at most to 5.

    That should fix it.
    Now let me try the category links.

    Many Thanks!!

  15. bmabetha
    Member
    Posted 2 years ago #

    To: abooze

    Thanks to you too man.
    Is finally working, I just removed this <?php global $query_string; query_posts( $query_string . '&posts_per_page=4'); ?>

    and went to dashboard > settings > reading and set Blog pages show at most to 5. as Xam 1.0 said and it worked well on all pages!

    But thanks to you too man.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags