Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Atahualpa 3 Wordpress theme (http://forum.bytesforall.com/forumdisplay.php?f=2)
-   -   [SOLVED] How to exclude posts in a category from appearing on the "blog"/multi-post p (http://forum.bytesforall.com/showthread.php?t=3500)

Shepherd Jim Sep 17, 2009 08:31 AM

[SOLVED] How to exclude posts in a category from appearing on the "blog"/multi-post p
 
Thanks to Flynn and Juggledad I've set up a special category "Announcements" whose latest post appears in a special box at the center top of my landing page ( http://forum.bytesforall.com/showthread.php?t=3392 )

NOW, I want to exclude ALL posts from the "Announcements" category from appearing on the multi-post "blog" page. It's okay if the "Announcements" category still appears in the "Category" sidebar widget so someone might be able to just see a chronological listing of all my announcements. I'd just like someone going to the "blog"/journal to not to be bothered with all the announcements.

Jim

juggledad Sep 17, 2009 10:00 AM

add this as the first line of 'The LOOP'
HTML Code:

<?php if ( !in_category('announcements') ) { ?>
and add this as the last line
HTML Code:

<?php } ?>
This will now only display posts that are NOT in the category 'announcements'

Shepherd Jim Sep 18, 2009 06:42 AM

That works a treat! :)

Now, I might seem picky here, but really it's mostly curiousity: I actually have been looking at some php coding pages trying to figure this out for myself, but php if/endif/else statements don't seem as intuitive as the good old BASIC and dBaseIV ones I remember from my youth. :o

How could I amend the code so that IF the current page is NOT the multi-post "blog" the loop DOES execute? That is, if someone specifically clicks on the "Announcements" category in the Category widget in the right sidebar they WOULD see the usual chronological listing of all the posts in that category.

(note: if the above is not possible, is there a way to have the "Announcements" category NOT appear ANYWHERE visible to the site visitor. I find it disconcerting that if you click on "Announcements" category in the Category widget you're presented with a page with an empty center column.)

I've been nosing around trying to figure out how mutli-category and single-category multi-post pages are differentiated with no luck.

Jim

juggledad Sep 18, 2009 07:02 AM

try this, change the if to
HTML Code:

<?php if ( !is_page('XXXXXXXX') OR (is_page('XXXXXXXX') AND !in_category('announcements')) ) { ?>
where XXXXXXXX= the name of your blog page

So this is saying 'if it's not the blog page OR it is the blog page, but the post is not in the category 'announcements', then display it

Shepherd Jim Sep 18, 2009 07:22 AM

Code:

<?php if ( !is_page('blogg') OR (is_page('blogg') AND !in_category('announcements')) ) { ?>
Nope, that's not it, we've worked all the way back to "normal" -- the posts in the "Announcements" category are showing up everywhere they normally would -- including the main, multi-post "all category" blog page.

http://www.shepherdjim.com/

I left the new "if" in place so you could check it out if necessary.

Jim

juggledad Sep 18, 2009 11:25 AM

Wow, this took me on a ride! for some reason is_page('blogg') doesn't work! However in your case since you are using a static front page , the blog page is refered to as the home page, so we can change the it to
HTML Code:

<?php if ( !is_home() OR (is_home() AND !in_category('announcements')) ) { ?>

Shepherd Jim Sep 18, 2009 02:04 PM

Okay! Wow! That did it!

The whole setup is working perfectly. I was worried that when I viewed a multi-post listing of the Announcements category if I clicked on a single post I'd again get a blank center column but the single post page opens up complete with comment window.

Thanks! Now I have to check with the Head Shepherd to see if she thinks this is ready to be implemented on the main site.

Jim


All times are GMT -6. The time now is 03:37 PM.

Powered by vBulletin® Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.