Title: coby604's Replies | WordPress.org

---

# coby604

  [  ](https://wordpress.org/support/users/coby604/)

 *   [Profile](https://wordpress.org/support/users/coby604/)
 *   [Topics Started](https://wordpress.org/support/users/coby604/topics/)
 *   [Replies Created](https://wordpress.org/support/users/coby604/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/coby604/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/coby604/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/coby604/engagements/)
 *   [Favorites](https://wordpress.org/support/users/coby604/favorites/)

 Search replies:

## Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Comments question](https://wordpress.org/support/topic/comments-question-4/)
 *  Thread Starter [coby604](https://wordpress.org/support/users/coby604/)
 * (@coby604)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/comments-question-4/#post-1888671)
 * I have done extensive research on comment counting or numbering comments, and
   I fail to see any solution that works for the latest version of wordpress (3.0.4)
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Comments question](https://wordpress.org/support/topic/comments-question-4/)
 *  Thread Starter [coby604](https://wordpress.org/support/users/coby604/)
 * (@coby604)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/comments-question-4/#post-1888666)
 * I don’t want the horizontal rule to display on the last comment, no matter how
   many comments there are so the first idea won’t work.
 * However, I agree with your second idea that if a variable is setup to count the
   number of comments and if the total number of comments is equal to the comment
   number then the horizontal rule is not displayed.
 * Sounds great, but I’m not sure how to write that code…
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [custom page/post navigation](https://wordpress.org/support/topic/custom-pagepost-navigation/)
 *  Thread Starter [coby604](https://wordpress.org/support/users/coby604/)
 * (@coby604)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/custom-pagepost-navigation/#post-1677528)
 * After some research and trial and error, I found a solution that works for me.
   There might be a simpler, cleaner way of achieving the same thing, but this is
   the code that I came up with that worked…
 *     ```
       if ( ! is_search()){ // if returning search results do not show any navigation
       	if ( ! is_single()){
       		$wp_query->is_single = true;
       		$next_post = get_adjacent_post(false,'',false) ;
       		$prev_post = get_adjacent_post(false,'',true) ;
       		if ($wp_query->current_post == $wp_query->post_count-1 && $wp_query->current_post !== 0) { // you're at the last post on the page
       			if(!get_adjacent_post(false, '', true)) {echo '<div class="post-newer post-newer-top"><p><a href="#post-'; echo $next_post->ID; echo '">< Newer Post</a></p></div>'; } // if there are no older articles
       			else {echo '<div class="post-newer post-newer-top"><p><a href="#post-'; echo $next_post->ID; echo '">< Newer Post</a></p></div>'; echo '<div class="post-older post-older-top"><p>'; $wp_query->is_single = false; next_posts_link('Next Page >', 0); $wp_query->is_single = true; echo '</p></div>'; }
       		}elseif ($wp_query->current_post == 0) { // you're at the first post on the page
       			if(!get_adjacent_post(false, '', false)) {echo '<div class="post-older post-older-top"><p><a href="#post-'; echo $prev_post->ID; echo '">Older Post ></a></p></div>'; } // if there are no newer articles
       			elseif(!get_adjacent_post(false, '', true)) {echo '<div class="post-newer post-newer-top"><p>'; $wp_query->is_single = false; previous_posts_link('< Previous Page', 0); $wp_query->is_single = true; echo '</p></div>'; } // if there are no older articles
       			else {echo '<div class="post-newer post-newer-top"><p>'; $wp_query->is_single = false; previous_posts_link('< Previous Page', 0); $wp_query->is_single = true; echo '</p></div>'; echo '<div class="post-older post-older-top"><p><a href="#post-'; echo $prev_post->ID; echo '">Older Post ></a></p></div>'; }
       		}else { // you're in one of the middle posts
       			if(!get_adjacent_post(false, '', false)) {echo '<div class="post-older post-older-top"><p><a href="#post-'; echo $prev_post->ID; echo '">Older Post ></a></p></div>'; } // if there are no newer articles
       			elseif(!get_adjacent_post(false, '', true)) {echo '<div class="post-newer post-newer-top"><p><a href="#post-'; echo $next_post->ID; echo '">< Newer Post</a></p></div>'; } // if there are no older articles
       			else {echo '<div class="post-newer post-newer-top"><p><a href="#post-'; echo $next_post->ID; echo '">< Newer Post</a></p></div>'; echo '<div class="post-older post-older-top"><p><a href="#post-'; echo $prev_post->ID; echo '">Older Post ></a></p></div>'; }
       		}
       		$wp_query->is_single = false;
       	}
       	else {echo '<div class="post-newer post-newer-top"><p>'; next_post_link('%link','< Newer Post',false); echo '</p></div>'; echo '<div class="post-older post-older-top"><p>'; previous_post_link('%link','Older Post >',false); echo '</p></div>'; }
       }
       ```
   
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [custom page/post navigation](https://wordpress.org/support/topic/custom-pagepost-navigation/)
 *  Thread Starter [coby604](https://wordpress.org/support/users/coby604/)
 * (@coby604)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/custom-pagepost-navigation/#post-1677522)
 * I’m not sure how to expand on this…
 * for example, I have my settings configured to show 5 posts per page. The navigation
   works fine until I reached that fifth post. At that point, the get_adjacent_post
   property will return true because there is another post, but it’s not on the 
   same page therefore the link doesn’t work.
 * So, I’m looking for a solution that figures out when a post is the last on the
   page, and when that happens change the link from:
    `<a href="#post-'; echo $prev_post-
   >ID; echo '">Older Post </a>` to something like this: `<a href="the next page"
   >Next Page </a>`
 * Does that explain my problem better??
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to get next post ID ?](https://wordpress.org/support/topic/how-to-get-next-post-id/)
 *  [coby604](https://wordpress.org/support/users/coby604/)
 * (@coby604)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/how-to-get-next-post-id/#post-1440813)
 * I figured out that adding this little bit of code:
 * `$wp_query->is_single = true;`
 * basically this will tell WP to treat the current page as a single page, even 
   if it’s your home page or main page with multiple posts on the page.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to get next post ID ?](https://wordpress.org/support/topic/how-to-get-next-post-id/)
 *  [coby604](https://wordpress.org/support/users/coby604/)
 * (@coby604)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/how-to-get-next-post-id/#post-1440812)
 * I realized that this only returns a result on the single permalink page. So I’m
   wondering if there is a way for this to work on the main page as well.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to get next post ID ?](https://wordpress.org/support/topic/how-to-get-next-post-id/)
 *  [coby604](https://wordpress.org/support/users/coby604/)
 * (@coby604)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/how-to-get-next-post-id/#post-1440811)
 * This is exactly what I’m looking for as well. However, I tried the exact code
   within my wordpress loop, and it didn’t return anything for me?
 * I’m running version 2.9.2
 * I also can’t find any documentation about the get_adjacent_post tag. Is this 
   tag still supported in the current version of wordpress?

Viewing 7 replies - 1 through 7 (of 7 total)