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 have a simple site that shows one random post when you reach it. This post then has a link below it that, when clicked, will pull in another random post to that homepage, excluding all posts from the category that the current post is in.

Eg. A post from category 'Bikes' is shown. Below it is a link that needs to replace that post with another random post from all the categories excluding the posts in 'Bikes'

I am finding it easy to find code for excluding a set category but i can't find a way to read what post category is shown on the page and exclude only that.

I would greatly appreciate any advice.

WordPress Version 3.1

share|improve this question
add comment

1 Answer

wp_get_post_categories() (Codex reference) is used to get the categories for a post

share|improve this answer
    
I'm not trying to get the categories for a post, I'm trying to get all the posts in a category but exclude the current post –  user983248 May 23 '12 at 12:38
    
@user983248 then you should ask a separate question. –  anu May 23 '12 at 14:17
    
Hi sorry, but I had two browsers windows and I got confused, This is not even my question. I was trying to reply to a comment on a question of my own. Sorry anu :) –  user983248 May 23 '12 at 17:08
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.