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 click on a link in my WP site to open a category archive. I see a list of posts for that category. I click on the permalink of one of those posts to see the full post.

at the top of the window are prev/next arrows. I click on them expecting to be taken to the prev/next post within the same category, but that doesn't happen. I'm taken instead to the prev/next post within the post_type=post collection of posts.

is it possible to set up the system so that when a post is displayed from a category archive, clicking on the prev/next buttons takes the visitor to the prev/next post within the same category?

update

I apologise for the lack of detail.
for those people who need more information...
the category archive/listing currently loads a default 'index.php' template.
each post within the archive list has a permalink link.
the permalink link loads a default 'single.php' template (note. there can only be one permalink per post)

Michael is correct. the theme is using the next_post_link() and previous_post_link() functions. the in_same_cat parameter is interesting but not really useful because it refers to the categories of the currently viewed post, not the category currently being viewed. a method would be needed to indicate that a specific category is being viewed, and it's id, so that the current page could point to the previous/next posts in that specific category rather than the complete collection of posts.

I'm wondering if the permalinks would need to be adjusted on the category archive page to indicate that a category is being perused; eg, add a query to the permalink; '&cat=7'. the single.php page could then check for presence of the query variable and react accordingly. if this method was used, would I need to use a non-core variable to prevent WP from loading the wrong template?

or... would it make sense to create a category.php page with a loop of only one post per page?

again, my apologies for not giving specifics in the initial question.

cheers,
Gregory

share|improve this question
    
the single post is output by single.php; the code for the arrows is likely made with codex.wordpress.org/Function_Reference/next_post_link - check the 'in_same_cat' parameter –  Michael May 6 '12 at 15:07
add comment

1 Answer

It sends you to the next/prev post by date of been published. I don't know what gives you these next/prev links and where (single.php, category.php, archive.php or any other custom template file).

Without knowing more (some code example) all that I can give to you is this:

$page_nr = '&paged=';
$page_nr = get_query_var( 'paged' ) ? $page_nr.get_query_var( 'paged' ) : ''; //<!-- tell wordpress this is paged
query_posts('cat=7&posts_per_page=6'.$page_nr); //<-- set cat= to the numeric category

if (have_posts()) {
    while (have_posts()) {
        the_post();

        // do your awesome WP loop stuff here
        <div><?php next_posts_link('Next Page &raquo;') ?></div>
        <div><?php previous_posts_link('&laquo; Previous Page') ?></div>
    }
}

That will help you, you may need to find how to get the current category that the user is currently browsing etc etc. Not the best fit, but it will help you to figure out the rest.

share|improve this answer
2  
@Michael 'the single post is output by single.php', NOT TRUE, We don't know how he outputs the single post, he can be using single.php, my-cat-single.php, or even categories.php or archive.php are able to output the post with some modifications. He is not posting the code, not specifying, where or what is outputting the post for which he needs to modify the next prev/links. You in the other hand are just assuming that is single.php while easily can be archive.php or the other options mentioned before. –  user983248 May 6 '12 at 16:40
    
@kaiser, thank you for the code. Paged is not the problem. I apologise for not giving you more information to work with. –  Gregory May 7 '12 at 5:05
1  
@ user983248, thank you for the whipping :-) is there a my-cat-single.php template? I haven't seen one mentioned in any of the template hierarchy documents I've read. –  Gregory May 7 '12 at 5:06
    
@Gregory I wasn't trying to solve your problem. Just taking care about that the answer doesn't throw errors. Q/A is for later readers also. –  kaiser May 7 '12 at 5:27
1  
@Gregory, That is because is a customization that you must perform, if you wish. –  user983248 May 7 '12 at 9:37
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.