Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Forum: Fixing WordPress
    In reply to: Comments question
    Thread Starter coby604

    (@coby604)

    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
    In reply to: Comments question
    Thread Starter coby604

    (@coby604)

    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…

    Thread Starter coby604

    (@coby604)

    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>'; }
    }
    Thread Starter coby604

    (@coby604)

    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??

    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.

    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.

    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)