Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

miles1234 on "How to stop 404 error on NEXT_POSTS() at end of stack?"

$
0
0

I have hacked up each main post (and each category post) so that it includes only an href tag around an image source. The href is to the link provided by 'next_posts()'

Clicking on the image displayed delivers the user to the next post, just as I want. (For example from, SITE.COM/wp/page/19 TO SITE.COM/wp/page/20.)

Problem is when you get to the last post you get 404 error. I want it to fail gracefully. When there are no more pages, I want to
1) at a minimum not give a 404, and even better to figure out how to
2) pop up a "The End" message or even
3) deliver the user back to the top of the stack (first post... that is, the most recent post)

How do I get NEXT_POSTS() to fail gracefully? Many thanks!

<?php $contentMH = get_the_content( $more_link_text, $stripteaser ) ?> <!-- GRAB CONTENT TO STRING -->

<?php $contentMHpieces = explode(">", $contentMH);?> <!-- EXPLODE CONTENT TO AN ARRAY -->

<!--WRITE SOME HTML -->
<a href= " <?php echo next_posts(); ?> ">
<!-- INCLUDE LINK TO NEXT POSTS-->

<?php echo $contentMHpieces[1].">"; echo $contentMHpieces[2].">"; ?>

Where
$contentMHpieces[0] is just thrown away because it is the permalink that I don't want.
$contentMHpieces[1].">" is the 'img src' etc. and
$contentMHpieces[2].">"; is the closing A tag.


Viewing all articles
Browse latest Browse all 8245

Trending Articles