hide specific posts from home page
-
In order to hide specific posts from my home page (post feed), I am using the following CSS. Is there a way I can consolidate this? Do you foresee any problems?
.home #post-195 .entry-title { display: none; } .home #post-195 .entry-content { display: none; } .home #post-195 .entry-footer { display: none; }I want to be able to do something like the following (which does NOT work)
.home #post-195 .entry-title .entry-content .entry-footer { display: none; }I would really appreciate any help anyone can give me on this.
Thanks
The blog I need help with is: (visible only to logged in users)
-
I think I may have solved this myself. Is this right?
.home #post-195, #post-197, #post-193, #post-191, #post-189, #post-187, #post-181, #post-179, #post-177, #post-243, #post-175, #post-173, #post-171, #post-169, #post-166, #post-162, #post-160, #post-156, #post-154, #post-152, #post-145 { display: none; } -
-
Hey there,
One alternative solution for consolidating all posts you wish to not display on your home page would be assigning each post a new Category, for example “Display-None”.
When you assign a Category to a post it then has a new class added to it, in the example above the new class would be class=”category-display-none” you then can target all posts assigned with this Category and hide them with:
.category-display-none { display: none; }This might end up just being about the same amount of work (or more depending on how many post you have to visit and add this Category to) as sorting out the post ID for each of them and adding them to your CSS as you have done above but it will save significant time in the future when wanting to add new posts but not have them display immediately on the homepage – simply assign them this Category and they will default to display none.
I believe the reason your above CSS is not working is because you have it set up to target only post 195 on the homepage, and then all other posts everywhere because each #postID is not accompanied by the .home class which is required in order for them all to be targeted there.
The appropriate CSS to have what you want take effect would be:
.home #post-195, .home #post-197, .home #post-193, .home #post-191, .home #post-189, .home #post-187, .home #post-181, .home #post-179, .home #post-177, .home #post-243, .home #post-175, .home #post-173, .home #post-171, .home #post-169, .home #post-166, .home #post-162, .home #post-160, .home #post-156, .home #post-154, .home #post-152, .home #post-145 { display: none; }If this still seems to effect the Category Searches as you have mentioned you may have to make them more specific by targeting only the post content area on the homepage by adding the content-area class between .home and #postID and applying to each targeted post, here is an example to test:
.home .content-area #post195 { display: none; }After all is said and done, it may just be more simple now and moving forward to visit each post and assign them the new “Display-None” Category and apply the CSS as mentioned initially.
Hope this helps!
Cheers
-
wow, I was able to follow you very well. Thanks for taking the time to help me. I think I will do the “Display None” category. But now will these posts still show up on searches and category archives. Let’s say I have a post that I has a “Display None” category, but I have also labeled it another category (e.g. “Episode Highlights”). I still want it to show up on the category page for “Episode HIghlights”.
-
What you may have to do is make your selector more specific so it only targets that Category on your homepage in the post content area. The CSS should then have no effect on the associated posts on any other pages.
Once the Category “Display-None” is assigned to the posts of your choosing, this CSS should do the trick:
.home .content-area .category-display-none { display: none; }Try it out and perform a Category Search and let me know if there are any issues. It is possible that the Category Search results may be returned on the homepage within the content area and if this is the case they will not display and we may have to adjust the code but it is more likely that the results will display on a separate page and the code will not effect it.
I look forward to your response!
Cheers
-
works perfectly so far
I added the following code using a category I already had for posts that show episode scenes with script and commentary
.home .content-area .category-episode-highlights {
display: none;
}They don’t appear on homepage (that’s what I want)
https://manifest828.wordpress.com/
They do appear on category search (like the way I want)
https://manifest828.wordpress.com/category/episode-highlights/
They appear in a search (like I want)
https://manifest828.wordpress.com/?s=dogs
Again thank you very much. You were very helpful. I have some other questions, but I will ask later and open up a new thread. If you see them, maybe you can help me with them, or someone else can, too.
-
- The topic ‘hide specific posts from home page’ is closed to new replies.