Community Forums › Forums › Archived Forums › Design Tips and Tricks › Modern Portfolio Pro- remove post info
- This topic has 5 replies, 2 voices, and was last updated 8 years, 5 months ago by Porter.
-
AuthorPosts
-
November 2, 2015 at 11:41 am #169897bburroMember
I am following these instructions https://my.studiopress.com/snippets/post-info/ to remove the post info from my site.
I pasted
//* Remove the post info function remove_action( 'genesis_before_post_content', 'genesis_post_info' );
at the end of my functions.php file... but it did nothing.
I know I can use the Simple Edits Plugin, but I want to do it this way-- or at least understand why what I'm doing isn't working 😉
Would future updates overwrite my functions.php-- and if so, I just need to make sure I copy my edits and paste them back after updating or...?
Thanks!
November 2, 2015 at 12:14 pm #169901PorterParticipantNovember 3, 2015 at 10:53 am #170009bburroMemberI am building my site on localhost, so link is not available at this time...
Thanks!
November 3, 2015 at 11:10 am #170015PorterParticipantThemes themselves generally don't get updates, just Genesis, so your code in functions.php is safe.
The code you added should work, assuming the info is currently displaying "before post content" and your hook is right, which I'm unfamiliar with the default location of whatever theme you're using. I don't know if your theme / site changes the location of where that is at any point, but that would be my guess as to what isn't working.
Try replacing that with:
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
As that's where my info is displayed by default (genesis_entry_header, not genesis_before_content).
November 3, 2015 at 12:23 pm #170040bburroMember@Porter--
Boom. You tha man!
Learning hooks- so that was the problem-- I was "hooked" into the wrong location, right?
So it's
what_to_do( 'heres_my_hook', 'heres_the_part_of_the_hook_I_want_to_modify', no idea);
I will go back and review their tutorial. This is essential!!
Thanks again for your help!
November 3, 2015 at 12:36 pm #170044PorterParticipantExactly - you were trying to remove post info from an area where it currently didn't exist! That doesn't throw an error (Genesis handles that silently), but it simply doesn't do anything if the item isn't there.
It's basically add_action or remove_action, hook_name, part you're modifying, priority. Priority (the number value) is where in the "stack" this action happens. This lets you determine if one hook happens before another, regardless of where in the code it is. A priority of 1 will happen first, where as 99 will happen alter - I believe the default is 12. This isn't too important, but a good example is if you remove something from one place, and add it to another place - you want to ensure the remove happens first, and the add happens after, so you can assign a priority of 11 to the remove, and 12 to the new add.
There's also filters, which allow you to change elements of the area you specify, like the footer.
You can also change the part of the hook you want to effect, to a custom function, and do anything you want, like so:
add_action('genesis_after_entry_content', 'anib_remove_post_info'); function anib_remove_post_info() { if (is_singular(array( 'venues' ))) { remove_action( 'genesis_after_entry_content', 'genesis_post_info', 18); } }
That COULD have just been:
remove_action( 'genesis_after_entry_content', 'genesis_post_info', 18);
but calling the custom function 'anib_remove_post_info' allowed me to specify that I only wanted the remove action to occur if I was on a page of the "venues" custom post type. If I did if(is_home()) the action would only happen on the front page, etc - it simply gives you further control.
Definitely read up on them / play around, it's crucial to a proper understanding of Genesis, and makes things REALLY easy once you get it.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.