Archived topic
Want to replace my previous social share bars
25 replies · Started by Eric on June 27, 2017
Hi Tom,
I've switched over to Generatepress and my pagespeed/size has never been better!
As I purge out old and bloated plugins, I've been really wanting to replace my social share bars with Elementor share bars.
I need help replacing the share bars in these exact spots (see screenshot) on posts only. Those locations don't seem to be in the GP Hooks module.
Screenshot:
https://ibb.co/efJ53Q
Thanks in advance.
Hi there,
There are actually more hooks than the ones the module. See list here: https://docs.generatepress.com/collection/hooks/
I think what you are looking would be these two:
https://docs.generatepress.com/article/generate_after_entry_header/
https://docs.generatepress.com/article/generate_after_entry_content/
Let me know if this helps.
Looks to be them, but I'm not sure what code to use to put the shortcode in there.
Try this:
add_action( 'hook_name', 'tu_add_social_icons' );
function tu_add_social_icons() {
echo do_shortcode( '[shortcode-here]' );
}
Replace hook_name with the name of the hook you want to use.
Thanks, Tom. I'll try this out shortly.
Looks like I was missing that "echo do_shortcode" part.
Using this, I'm not seeing the shortcode working at all (regardless of which hook_name I'm using. Adding the shortcode directly to the GP Hooks module will get it working, but in the wrong spot:
add_action( 'generate_after_entry_header', 'tu_add_social_icons' );
function tu_add_social_icons() {
echo do_shortcode( '[elementor-template id="20458"]' );
}
Can you link me to the page it's supposed to show up on?
I'm testing it on a private staging site right now. I've put that code in my child theme's functions.php.
Should it go somewhere else?
Success!
I decided to add the code to the Code Snippets plugin and it worked - so I went back and caught something I overlooked in the file. All is well - thank you for the help!
Glad you got it working :)
Ok, quick question:
I added a second share bar using the "generate_after_entry_content" location hook and it's showing up below the related posts section. How do I get the share bar to be right above the related posts like in my screenshot in the OP?
Unfortunately this is due to how the related posts add their code. They typically filter into the end of the content, as the plugin doesn't know if any hooks exist.
The only way to do it would be if the related posts plugin can disable automatic output, and you can add it yourself to the hook.
No worries, Tom.
I'm using Jetpack and the related posts that it comes with. I'll ask them if this is possible on their end (I believe they allow for modification of where it goes, but I'm not savvy enough to understand it all).
I'll report back here when I get more info.
Hey guys, I've just updated to GP Premium 1.4.1 and it looks like my social share buttons moved from being under the featured image (where I want it) to under the post meta using the "generate_after_entry_header" hook.
Did the location change with this new version? I'd like to move those buttons back below the featured image.
Thanks.