Community Forums › Forums › Archived Forums › Design Tips and Tricks › Remove Post Meta from category pages but not posts
- This topic has 13 replies, 3 voices, and was last updated 8 years ago by GokulDeepak.
-
AuthorPosts
-
October 17, 2015 at 5:17 pm #168352nateMember
Hi there
I've been trying to figure this out for a bit now but can't quite get it from searching on google and on this forum.
I want the post meta and post info on my blogroll and my category pages to not show up but still show up on the individual posts.
I tried this code in Functions PHP:
//* Remove post meta from archive pages remove_action('genesis_entry_footer', 'genesis_post_meta', 12); remove_action('genesis_entry_header', 'genesis_post_info', 12); add_action('template_redirect', 'child_conditional_actions'); function child_conditional_actions() { if( is_single() ) { add_action('genesis_entry_footer', 'genesis_post_meta', 12); add_action('genesis_entry_header', 'genesis_post_info', 12); }}
Which I found at http://blogaliving.com/genesis-how-to-place-the-post-meta-and-info-just-on-single-pages/#comment-1207
And then I removed the second "add_action" because it was showing the post meta twice on both the cateogry pages and the individual posts.
The result I get at the moment is that the code works for the "post info". i.e. it doesn't show on the category pages or front page but does on the individual posts.
But the "post meta" is still showing up on both.
Does anyone know anything to try to make this work properly. I tried several different codes but this one has me the closest - just not quite there.
Any help is much appreciated.
Cheers,
NateP.S: The code is currently on this site which I use to test stuff - http://testitout2.siterubix.com/
But eventually I will put it on http://sixstringacoustic.com
http://sixstringacoustic.com/October 19, 2015 at 1:23 pm #168508PorterParticipantThis should do the trick:
// Remove Post Info, Post Meta from Archive Pages function themeprefix_remove_post_meta() { if (is_archive()) { remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); } } add_action ( 'genesis_entry_header', 'themeprefix_remove_post_meta' );
Rather than remove it, then add it back, we're simply adding a conditional check to see when we should remove it, and only removing it then.
October 27, 2015 at 2:40 pm #169247nateMemberHi Porter
Thanks for this. Sorry for the late reply here. I thought I had clicked notify me of follow-ups via email but I mustn't have!
This code has worked perfectly for category pages - i.e. they now don't show post meta or post info and do show the post meta and post info on the individual posts.
However, the post meta and post info still show on the front page (I'm using the "your latest posts" for the front page option in wordpress writing settings). Do you know if there's a way that I can also have it so that the post meta and post info doesn't show on the front page?
i.e. is there a condition like:
if (is_frontpage())
That I could add into that code to do that?
Thanks for all your help so far. Much appreciated.
Nate
October 27, 2015 at 2:53 pm #169250PorterParticipantThere is exactly that function haha
// Remove Post Info, Post Meta from Archive Pages
function themeprefix_remove_post_meta() {
if (is_archive() || is_front_page()) {
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
}
}
add_action ( 'genesis_entry_header', 'themeprefix_remove_post_meta' );|| means "or", so we're simply checking to see if it's an archive, OR the front page, and we remove them if it's either.
October 27, 2015 at 3:22 pm #169255nateMemberHi
Thanks for your speedy reply!
I added that in and the post meta and post info is still showing on the front page and it's now also showing up again on the category pages.
This is exactly what's in my functions.php
// Remove Post Info, Post Meta from Archive Pages function themeprefix_remove_post_meta() { if (is_archive() || is_front_page()) { remove_action( ‘genesis_entry_header’, ‘genesis_post_info’, 12 ); remove_action( ‘genesis_entry_footer’, ‘genesis_post_meta’ ); } } add_action ( ‘genesis_entry_header’, ‘themeprefix_remove_post_meta’ );
Thanks so much for your help so far.
October 27, 2015 at 3:25 pm #169256PorterParticipantHmm, I could see it showing up on the front page still, not sure why it came back on the archive pages, but moving on! Try this:
// Remove Post Info, Post Meta from Archive Pages function themeprefix_remove_post_meta() { if (is_archive() || is_home()) { remove_action( ‘genesis_entry_header’, ‘genesis_post_info’, 12 ); remove_action( ‘genesis_entry_footer’, ‘genesis_post_meta’ ); } } add_action ( ‘genesis_entry_header’, ‘themeprefix_remove_post_meta’ );
If that doesn't work, simply try this to see if only the front page is fixed:
// Remove Post Info, Post Meta from Archive Pages
function themeprefix_remove_post_meta() {if (is_front_page()) { remove_action( ‘genesis_entry_header’, ‘genesis_post_info’, 12 ); remove_action( ‘genesis_entry_footer’, ‘genesis_post_meta’ ); } } add_action ( ‘genesis_entry_header’, ‘themeprefix_remove_post_meta’ );
Also try is_home in that last example if it doesn't work.
October 27, 2015 at 3:52 pm #169263nateMemberGot it to work!
Thanks so much. Very much appreciated.
I first tried with just the
is_front_page
and that didn't work but then I used the original code you gave me and replaced theis_archive
withis_front_page
and that worked for the front page and then I added in the|| is_archive())
and now it works for both.So final code, for anyone else who's having difficulty with this, was:
// Remove Post Info, Post Meta from Archive Pages function themeprefix_remove_post_meta() { if (is_front_page() || is_archive()) { remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); } } add_action ( 'genesis_entry_header', 'themeprefix_remove_post_meta' );
Thanks Porter!
October 27, 2015 at 3:56 pm #169266PorterParticipantInteresting, so you're saying the order of is_archive and is_front_page mattered? To the very best of my knowledge, it shouldn't, so now I need to go make a test! Glad you got it working, good luck with the site.
October 27, 2015 at 4:01 pm #169267nateMemberI'm not sure if the order made any difference. I think it was more copying the original code that you sent me in and adding in the || that did the trick. Maybe there was a small typo somewhere in the second lot of code. I'll give it a look.
After looking in there the only difference I can see from the first code to the second code is that there was no indentation in parts of the second lot of code that there were in the first code you sent. I'm not sure if this indentation makes any difference?
October 27, 2015 at 4:02 pm #169269PorterParticipantIt shouldn't matter, I personally prefer no spacing, while most php adds space. Running a test now to put my mind to rest.
October 27, 2015 at 4:16 pm #169270PorterParticipantJust confirmed, order doesn't matter - phew, my brain almost fried haha - thought there might be some very odd logic in the is_front_page function that required it go first, which makes no sense. You must have copied something wrong or had one small change, but no worries, all is good 🙂
October 27, 2015 at 4:37 pm #169275nateMemberGood to know.
Yeah I must've missed something. Glad it's working now.
One more small thing - only if it's an easy thing to figure out, I don't want to take up much more of your time.
Now that the post meta is gone it also gets rid of the underline at the bottom. Is there an easy way to add back an underline?
October 27, 2015 at 4:50 pm #169277PorterParticipantEach post has 3 main css sections, entry-header, entry-content, and entry-footer. Knowing this, the ideal solution (most likely), would be to apply an border-bottom to the entry-footer (bottom of each post). Add this style.css (or search for.entry-footer and add the border property below to that section):
.entry-footer { border-bottom: 1px solid #000000; }
Change #000000 to whatever color you want (that'll be black, in case you're unfamiliar with hex), and change the 1px to a larger value if you want the line to be thicker. Lastly, add some padding above and below if the line is too close to the next post / end of your current post to get the spacing just right. Let me know how it goes.
December 4, 2016 at 4:13 am #196963GokulDeepakMemberIt works. Thank you guys. And it is interesting about that preference of first condition.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.