WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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

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

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.