Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

in my single.php i have a link back to the category:

$category_id = get_the_category(); $category_link = get_category_link( $category_id[0]->cat_ID );

If i am now coming from page 2 to the single, is there a way to go directly back to the second page?


Edit

is there a better way than using the js history.back() method?

share|improve this question
add comment

migrated from stackoverflow.com May 20 '11 at 5:18

This question came from our site for professional and enthusiast programmers.

1 Answer

You could try:

<?php
if ( ! empty ( $_SERVER['HTTP_REFERER'] ) )
{
?>
    <a href="<?php echo esc_url( $_SERVER['HTTP_REFERER']; ) ?>">Go Back</a>
<?php
}
share|improve this answer
    
And to expand on that, you could do an if statement to change which version of the link shows: if($_SERVER['HTTP_REFERER']) { referer link } else { normal link } –  Tristar Web Design May 19 '11 at 20:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.