Community Forums › Forums › Archived Forums › General Discussion › exclude post info in a specific category
- This topic has 11 replies, 3 voices, and was last updated 10 years, 7 months ago by asdweb.
-
AuthorPosts
-
September 13, 2013 at 1:46 pm #62331asdwebMember
What I want to exclude in a specific category (or two) is:
1- post date and post author
2- filed under: category
3- comment option (i know there's an allow comment check box, but want to do this automatically if possible)I've tried a bunch of scripts and nothing is working to isolate just the category I've identified.
Thanks.
Amy Susan Design.com @AmySusanDesign
September 13, 2013 at 1:56 pm #62335wpspeakMemberI think I've done this before and it's not that hard.
Btw, here's a tutorial that might be useful http://wpsites.net/web-design/modify-post-info-genesis/
September 13, 2013 at 2:19 pm #62341asdwebMemberThis is the script I was trying to use. It didn't work AND it only addressed the post date and post author. :/
Amy Susan Design.com @AmySusanDesign
September 13, 2013 at 2:29 pm #62345Brad DaltonParticipantDo you have the Genesis Simple Edits plugin installed?
Which snippet did you use which didn't work?
I'll test it for you.
You can also do this using CSS code which is included in the tutorial.
Did you want to exclude the post info and meta from the category archive or single posts?
September 13, 2013 at 2:52 pm #62359Brad DaltonParticipantI tested this code and it works:
.category-web-design .post-info .author, .post-info .date { display: none; }
This is the code (above) in the tutorial:
.category-web-design .categories { display: none; }
This code(above) removes the categories (filed under) from the web design category:
.category-web-design .post-info { display: none; }
This code removes all the post info.
You can also use the category id in the CSS which you can grab using Firebug or from your source code.
The PHP may not work if you are using other code to filter or hook into the post info or meta or you have a plugin installed which does this as well.
Also the loop hooks have changed so you need to check these as well for child themes running XHTML or HTML 5 markup.
The tutorial i wrote only deals with the post info.
September 13, 2013 at 2:53 pm #62360asdwebMemberNo (Geneis Simple Edits).
I want to remove the post info and meta from all posts with the category "teachers." Probably the category archive, although there is a single post php set up.I used this one:
// Remove the post info function
remove_action( 'genesis_before_post_content', 'genesis_post_info' );add_filter( 'genesis_post_info', 'remove_post_info_exclude_teacher_category' );
/**
* @author Brad Dalton
* @link http://wpsites.net/web-design/modify-post-info-genesis
*/
function remove_post_info_exclude_teacher_category($post_info) {
if ( in_category('news') ) {
$post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit]';
return $post_info;
}
}
Amy Susan Design.com @AmySusanDesign
September 13, 2013 at 3:06 pm #62363Brad DaltonParticipantI worked out the problem.
You need to remove the shortcodes for the post info which you want to remove from the code.
So if you only want to remove the date and author, you simply remove those shortcodes only from the code and leave the others which you want to keep displayed like the comments link:
Here's the code:
Note: This code will not work if you have the Genesis Simple Edits plugin active.
https://gist.github.com/braddalton/6556043
September 13, 2013 at 3:49 pm #62371asdwebMemberWhat I've done:
Inserted your code above into function.php
Assigned "web design" category to posts I WANT to remove the post_info from.It removes the date and author from ALL posts, regardless of the category assigned and whether or not I have the shortcodes in the $post_info section or not.
Have not fiddled with the css.
Amy Susan Design.com @AmySusanDesign
September 14, 2013 at 6:24 am #62479Brad DaltonParticipantDid you want to exclude the post info from the category archive or single posts assigned to that category?
The conditional tags are different.
This is the conditional you should use:
in_category
The above works for all posts in that category
The below works when the page is category web-design
is_category
September 14, 2013 at 8:42 am #62504asdwebMemberI've tried is_category and in_category. It still removes the date + author name from ALL posts.
Amy Susan Design.com @AmySusanDesign
September 14, 2013 at 9:19 am #62524Brad DaltonParticipantThe code i posted above works as its tested.
Please paste your exact code in Pastebin or Github Gists and link top it form here so i can test it. Thanks
September 14, 2013 at 9:46 am #62526asdwebMemberit's here: http://pastebin.com/vsW5yq09
the only difference with is_category and in_category is that in_category puts "Leave a Comment (Edit)" at the top of the page.
I know what I want can be done. I'm about ready to scrap this theme and move to one that already has this feature, (i.e. Executive) or port over the single-portfolio.php and scrap the existing page_portfolio.php.
Amy Susan Design.com @AmySusanDesign
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.