• I’m having an issue with pagination on my site that I’m currently building.

    I’m displaying one post per page and my navigation moves from post to post (next, previous post). I’ve used this code:

    <div id="navigation">
        <ul>
          <li><?php next_post_link(); ?></li>
          <li>Comment</li>
          <li><?php previous_post('%','&laquo; ', 'yes'); ?></li>
        </ul>
      </div>

    I want to figure out how to determine if it’s the first post or last post and hide the li html tag depending on what the scenario is. So if I’m on the first post I would like to hide this:

    <li><?php next_post_link(); ?></li>

    Likewise, if I’m on the last post I would like to hide this:

    <li><?php previous_post('%','&laquo; ', 'yes'); ?></li>

    Currently it spits out empty li HTML tag.

    See example here: http://photo.alenabdula.com

    I’m stuck any help would be appreciated.

    -Alen

Viewing 1 replies (of 1 total)
  • Thread Starter alenxVR6

    (@alenxvr6)

    OK i think i figured it out. Here’s the code:

    <div id="navigation">
        <ul>
          <li<?php if(!get_adjacent_post(false, '', false)) { echo ' class="hide"'; } ?>><?php next_post_link('%link', 'Next &raquo;'); ?></li>
          <li>Comment</li>
          <li<?php if(!get_adjacent_post(false, '', true)) { echo ' class="hide"'; } ?>><?php previous_post_link('%link', '&laquo; Previous'); ?></li>
        </ul>
      </div>

    I’ll just hide the li HTML tag with CSS

Viewing 1 replies (of 1 total)
  • The topic ‘Paggination Issue’ is closed to new replies.