|
#1
Nov 10, 2010, 08:36 AM
|
|
Hi there,
I'd like to exclude some categories from showing on the homepage. This is the site - http://twh.net.au/alex/
I'm trying to exclude the 'worklist' category (the posts 2009, 2008, 2007 etc)
There was another thread here - http://forum.bytesforall.com/showthread.php?t=9927
I used the code suggested there, and changed the numbers to my specific category ID's (4 and 5), ending up with this:
PHP Code:
<?php if (is_front_page() && !is_paged() ) $posts = query_posts($query_string . '&cat=-4,-5'); ?>
But unfortunately its not working for me. Can anyone suggest what I'm doing wrong?
WP 3.0.1
Atahualpa 3.5.3
Last edited by thesis; Nov 10, 2010 at 09:22 AM.
|
#2
Nov 15, 2010, 08:55 AM
|
|
Try to delete minus before numbers. Works perfect for me without minuses.
|
#3
Nov 15, 2010, 01:49 PM
|
|
|
|
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
|
|
Where did you put the code?
Is the front page displaying your blog?
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
|
#4
Nov 15, 2010, 03:41 PM
|
|
Above loop. My frontpage shows posts only from specified category.
|
#5
Nov 15, 2010, 05:23 PM
|
|
|
|
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
|
|
How have you set that up - ie the front page to only display from certian categories?
In order to know why this code isn't working, I have to know what code is being run to create the front page. Since it is not the normal code, what is it?
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
|
#6
Nov 16, 2010, 04:17 AM
|
|
You can view this php code running in my website - www.docs.e7.lt
Above the loop full code
Code:
<?php if (is_front_page() && !is_paged() )
$posts = query_posts($query_string . '&cat=1'); ?>
<?php /* For the plugin Page2Cat http://wordpress.org/extend/plugins/page2cat/ */
if( is_category() AND function_exists('page2cat_output')) { page2cat_output($cat); } ?>
|
#7
Nov 16, 2010, 05:01 AM
|
|
|
|
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
|
|
Where did you put the other code - with the minus signs??
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
|
#8
Nov 16, 2010, 05:57 AM
|
|
I did not put code with minus. Just a code which is in the above post.
|
#9
Nov 16, 2010, 06:17 AM
|
|
|
|
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
|
|
aclime - I'm sorry I think there was an mis communication here. My first reply was to 'thesis' and so was your's but I thought you were having an issue. Now that I look at this again, you were just trying to give an answer (correct?)
While your code works for you because if just lists the items from a SINGLE category, 'thesis' is trying to display posts from ALL categories EXCEPT the two specified in the code.
thesis - are you still having a issue?
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
|
#10
Nov 17, 2010, 04:40 AM
|
|
Quote:
Originally Posted by juggledad
thesis - are you still having a issue?
|
Hi juggledad,
I just started working on this project again, so hadn't checked this thread in a few days. Really appreciate yours and aclime's input, thanks!
I'm still having an issue. Removing the minus signs caused the homepage to show only categories 4 and 5. I'm trying to exclude those categories from showing on the homepage.
|
#11
Nov 17, 2010, 04:45 AM
|
|
|
|
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
|
|
With the minus signs in, which posts on the front page ARE in one of those two categories?
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
|
#12
Nov 17, 2010, 05:35 AM
|
|
Quote:
Originally Posted by juggledad
With the minus signs in, which posts on the front page ARE in one of those two categories?
|
The post '2009' is in category 5 (its currently sticky on the homepage)
http://twh.net.au/alex/
I'm moving a few things around at the moment, apologies. The current homepage will soon be moved, and will be reachable under a 'News' menu item.
|
#13
Nov 17, 2010, 05:49 AM
|
|
|
|
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
|
|
if it is a sticky, new rules apply - a sticky by its nature is displayed first
Why not just 'unstick' the post?
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
|
#14
Nov 17, 2010, 06:26 AM
|
|
Ah, I see...
The reason I stickied the post was actually to solve another issue, which is this - I'd like the posts in category 5 (Works) to display without the kicker. If you go to http://twh.net.au/alex/category/worklist/ you'll see why. The 2009 post is showing without the kicker (post date), this is what I'm trying to achieve for all posts in category 5. Making those posts into stickies was one way to solve this, apart from the problem that those posts are also stickied on the homepage.
Maybe I should be looking at the problem differently.
Is there a way to remove the kicker from posts in a specific category instead? In my case, I'd need all posts from category 5 (Works) to display without the kicker. That way, I can un-sticky the posts to stop them showing on the homepage.
|
#15
Nov 17, 2010, 07:38 AM
|
|
|
|
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
|
|
sure, in 'The LOOP' you could change the line
HTML Code:
<?php bfa_post_kicker('<div class="post-kicker">','</div>'); ?>
to
HTML Code:
<?php if (!in_category( array( 4,5 ) ) ) bfa_post_kicker('<div class="post-kicker">','</div>'); ?>
So as long as the post is NOT in cat 4 or 5, the kicker will be displayed.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
|
#16
Nov 18, 2010, 05:30 AM
|
|
Thanks juggledad, it worked!
|
|