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?


1 Answer 1


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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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