Community Forums › Forums › Archived Forums › Design Tips and Tricks › Exclude Category from Homepage Not Working!
Tagged: css, Daily Dish, exclude category
- This topic has 7 replies, 4 voices, and was last updated 8 years, 8 months ago by inkmuser.
-
AuthorPosts
-
March 2, 2015 at 5:56 pm #142948nuenaMember
Hey everyone, I'm using the Daily Dish theme and I'm trying to exclude a category from the homepage. I used this code, which was sent to me by someone at Studiopress, but it is not working (I pasted it into the functions.php file and changed the number to the appropriate category id)
Any idea why this isn't working? I really don't want any of the "income reports" category to appear on the homepage but this code does not seem to be working... the website is http://www.fryhole.com
http://www.fryhole.comadd_action( 'pre_get_posts', 'exclude_category_posts' ); /** * @author Brad Dalton - WP Sites * @example http://wpsites.net/web-design/exclude-category-posts-page/ */ function exclude_category_posts( $query ) { if( $query->is_main_query() && $query->is_home() ) { $query->set( 'cat', '-263' ); } }
March 2, 2015 at 7:12 pm #142958ChristophMemberIf you are using a static page as homepage try using
is_front_page
instead ofis_home
.http://www.wpexplorer.com/wordpress-homepage-conditional/
March 2, 2015 at 7:18 pm #142959nuenaMemberThanks for the reply. The theme is set up as "show posts" and each section is its own widget. I really didn't do anything to this theme besides change some CSS, so functionally it should work, I don't understand why this doesn't isn't working!
I tried both is_home and is_front_page and neither of them work. Agh!
March 2, 2015 at 7:43 pm #142962ChristophMemberOk. I think I didn´t understand you right.
Let´s try again 🙂
You don´t want the income reports to show up in the recent post widget in the sidebar?
March 2, 2015 at 8:00 pm #142965ChristophMemberIf you want to exclude the category in the featured widget on the bottom, you can install the Genesis Sandbox Featured Content Widget Plugin and exclude the category by entering the id number of the category in the field "Exclude Terms by ID ".
March 2, 2015 at 11:11 pm #142975nuenaMemberHI Christoph,
Thanks so much for suggesting the Genesis Sandbox Featured Content Widget plugin... I downloaded it and it works! Yay! Didn't know that plugin existed, so helpful!! THANK YOU!
Kira
March 3, 2015 at 2:52 am #143004Brad DaltonParticipantThe code won't work for the blog page template and pre_get_posts won't work using the is_front_page() conditional tag.
If you're using the default reading settings and your frontage displays posts, it will work but not when using a front-page.php file or when using a static page as your posts page in your reading settings.
You can use the Genesis > Theme Settings > Blog Page Template > Exclude the following Category IDs: to exclude category I,D's from your blog page template
August 8, 2015 at 1:40 pm #161795inkmuserMemberThe exclude category doesn't work for me...the cat I want hidden still shows!
Using "latest posts" front page settings, Focus Pro theme.
Anyone have an idea why this isn't working?
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.