[wp-hackers] need help with loop code

Chris Jean gaarai at gaarai.com
Tue Feb 10 18:48:37 GMT 2009


Here's a code snippet that I have running on my site that can be easily 
modified to your situation:

$categories = get_the_category();

if ( empty( $categories ) )
    return;
if ( ( 1 === count( $categories ) ) && ( 1 == $categories[0]->cat_ID ) )
    return;

Let me know if this works for you.

Chris Jean
http://gaarai.com/
http://wp-roadmap.com/
http://dnsyogi.com/



Jen Simmons wrote:
> Hello hackers,
>
> I'm writing loop code for home.php, and I'm stuck.
>
> I started with
> <?php if ( in_category('6') && is_home() ) continue; ?>
>
> Which excludes all posts with category 6 from the home page. But the 
> client wants all posts with cat 6 to print, if they are also makred 
> with a second category, and to not show up only if cat 6 is the only 
> cat the post has.
>
> How can I do that?
>
> In other words, I need the code to read:
>
> If you have only one category, and that category is #6, then jump 
> ahead and don't do this stuff,
> otherwise,
> do do this stuff (printing stuff).
>
> thanks,
> Jen
>
> Jen Simmons
> Milkweed Media Design
> http://milkweedmediadesign.com
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list