[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 |
add this as the first line of 'The LOOP'
HTML Code:
<?php if ( !in_category('announcements') ) { ?> HTML Code:
<?php } ?> |
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 |
try this, change the if to
HTML Code:
<?php if ( !is_page('XXXXXXXX') OR (is_page('XXXXXXXX') AND !in_category('announcements')) ) { ?> 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 |
Code:
<?php if ( !is_page('blogg') OR (is_page('blogg') AND !in_category('announcements')) ) { ?> http://www.shepherdjim.com/ I left the new "if" in place so you could check it out if necessary. Jim |
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')) ) { ?> |
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 08:37 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.