WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

i'm having a problem with wordpress and the post-page: my web has several pages like: news, projects, links each page is displaying posts of the corresponding category.

my question: when clicking on a post's detail, it will execute always the same script (post-detail.php). now i want to implement a "back"-link which jumps page to the referring page. how can this be done? is it possible having several post-pages?


share|improve this question
up vote 1 down vote accepted

You can do that:

//add reff to query vars to hold the referring page ID
add_filter('query_vars', 'my_query_vars');

function my_query_vars($vars) {
    // add movies_view to the valid list of variables
    $new_vars = array('reff');
    $vars = $new_vars + $vars;
    return $vars;

then add ?reff=<?php echo $post->ID; ?> to your "post's detail" link

and on your "post-detail.php" you can create a back link using that query var

<a href="<?php echo get_permalink(get_query_var('reff')); ?>">Go Back</a>

and as for having several post-pages take a look at:

How to quickly switch custom post type singular template

share|improve this answer
wow - excellent! thanks a bunch! – Fuxi Mar 9 '11 at 14:40

Your Answer


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.