-
ambo100Participant
Thanks for creating the theme and sharing it, It’s exactly what I was looking for and I happened to come across it by chance.
I’d like to be able to blacklist certain categories of posts from appearing on the front page which is currently in the grid layout. Can a feature be implemented to support this or is there a simple workaround?
Daniel TaraKeymasterIn functions.php rewrite the function
esplanade_ignore_sticky_posts()
like so:function esplanade_ignore_sticky_posts( $query ) { global $wp_the_query; if( ( $wp_the_query === $query ) && $query->is_home() && esplanade_get_option( 'slider' ) ) { $query->set( 'ignore_sticky_posts', 1 ); $query->set( 'cat', -4 ); } }
Replace the number with the ID of the category you wish to exclude.
- This reply was modified 12 years, 8 months ago by Daniel Tara.
EddyParticipantJust tried this and it crashed the site, had to restore the function.php file. Apparently it conflicted with line 4, which I modified per another thread to keep from repeating the sticky posts on the front page. Any chance I’d be able to do both?
EddyParticipantNever mind, figured it out. Amazing the havoc an extra bracket can bring! Anyway, is there a way to ignore/block more than one category? I tried using -72, -93, etc, but it would only take the first.
EddyParticipantThis is blacklisting the blocked category not only from the front page, but also from the category page and the back end as well, only accessible by entering the direct URL… I had to undo the changes. Please advise.
Daniel TaraKeymasterThe
$query->is_home()
conditional assures this doesn’t happen. make sure you have it there.kri8tivParticipanthi Daniel,
the solution you have given is good but sorry to say that it is not so great. I will tell you why, for example I have 100 categories and as the time goes by, the more you post the more categories you will discover to create. If I only wish one category to be displayed on the homepage, it means I have to exclude the other 99 – one by one i have to exclude them, and if there’s new category, i have to go there again to edit the function.php. In other words, for me it’s complicated.
suggested solution:
is there a solution that we can make it the other way around? instead of “exclude” reverse it to “include”. in that way, i only need to assign one (1) category to feature on the homepage.what do you think?
Daniel TaraKeymasterIf you’re having 100 top-level categories you’re doing a pretty bad job organizing your content. Categories are hierachical so you can make categories children of other categories. Then when you exclude a parent category all the posts assigned to children categories will be ignored as well.
As for including only a certain category, you have the
cat
argument which does just that. In fact you can include more than one category.kri8tivParticipantI don’t have 100 top-level categories :-), it was just an example to show you that it was complicated to exclude all the other categories if you only want to show one category.
Can you teach me how to include only a certain category on the homepage besides sticky posts on the slider?
gusandrewsParticipantkri8tiv, there are plugins which do a pretty decent job of limiting front-page content to certain categories. I am using PE Category filter (http://pavelespinal.com/resume/downloads/) with Esplanade and it’s working pretty well (though it doesn’t solve my own problem, which is getting posts to appear in three distinct categorized columns).
Tagged: category front page filter
You must be logged in to reply to this topic.