An array to display entries that are in category A and B, A and C (WordPress)

The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

An array to display entries that are in category A and B, A and C (WordPress)

Hello,

not sure whether this is the correct forum (as it's related to WordPress) but, given it's PHP, I hope it's acceptable.

I know nothing about PHP and am trying to display one entry that belongs to category a (featured category) and b (other category), one entry belonging to category a and c, and so on.
Categories b, c, d, e, f, etc. are not sub categories. They are all top level categories.

I assume one would do that with an array?

In my own primitive terms, here is what I mean:

if entry is in the featured category (a) AND if entry is in category (b),
then output entry,

if entry is in the featured category (a)AND if entry is in category (c),
then output entry,

else, don't display anything.

So, basically, I'm trying to get entries to display that are in category a and category b, in category a and category c.

I haven't a clue how I'd go about translating this into a proper PHP function for WP.

What I want to do is display entries that are in category a AND category b, in category a AND category c, category a AND category d. The "so on" was meant to denote that I'd have entries that belong to categories a AND e, a AND f, a AND h, a AND z.

Edited to add:

If I'm not mistaking, then there are two conditions that need to be met. The first condition is that the entry is in category a. The second condition is that the entry must also be in another category (namely either b, c, d, e, f, g, ...), so something like:

I'm thinking this might be a better example with code. The issue that I'd like to display posts that are in category a as the main condition. When that condition is met, then the loop would come into play outputting the category b.

So (and I know this isn't correct but I hope it visualizes the idea), what I'm looking to do is for the loop to take action if it belongs to category a (featured category), and if the entry is in category a, then display the entry that is in category a and also in category b which would in turn allow me to display one featured entry of each category:

Output example (where "featured" is category A), ergo displaying one featured entry for each category:

Edit: I think this is a lot more difficult than I had imagined. After lots of searching, I found the Arthemia Theme which does exactly what I am trying to convey (see sidebar), so I think it's best if I purchase that theme.

I'm thinking this might be a better example with code. The issue that I'd like to display posts that are in category a as the main condition. When that condition is met, then the loop would come into play outputting the category b.

So (and I know this isn't correct but I hope it visualizes the idea), what I'm looking to do is for the loop to take action if it belongs to category a (featured category), and if the entry is in category a, then display the entry that is in category a and also in category b which would in turn allow me to display one featured entry of each category:

Output example (where "featured" is category A), ergo displaying one featured entry for each category:

Edit: I think this is a lot more difficult than I had imagined. After lots of searching, I found the Arthemia Theme which does exactly what I am trying to convey (see sidebar), so I think it's best if I purchase that theme.

Gotcha.
There are other themes out there that do this too

You define a "Featured" category in the settings then can assign the posts to that one and the others, just like you want.

Thanks, ToddW. I'll check out the WP themes repository to see if there is one that has this functionality.

It really irks me that I'm not getting a grasp on how this could work. I just know that the ingredients would be the get_posts (or query_posts), $cat_id, some SQL, and conditionals. How to put these together to make a working sample that'd output it the way I have described goes way beyond my head.

As I've wanted to learn PHP and SQL anyway, I might just do it now. Then I may be able to do these things all by myself in a year from now.