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.

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?

thanks

share|improve this question
add comment

1 Answer

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
add comment

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.