Sign up ×
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?


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

share|improve this question

migrated from May 20 '11 at 5:18

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

1 Answer 1

You could try:

if ( ! empty ( $_SERVER['HTTP_REFERER'] ) )
    <a href="<?php echo esc_url( $_SERVER['HTTP_REFERER']; ) ?>">Go Back</a>
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

Your Answer


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