Archived topic
Social icons in the blog footer using generate_after_content
9 replies · Started by Carrie on September 24, 2019
Good afternoon! I'm trying to insert Font Awesome icons at the bottom of each blog post using the generate_after_content hook, and I don't really understand how to do this. After reading the help documentation, I came up with the below code, but publishing it generates an error message - "Parse error: syntax error, unexpected '}', expecting end of file in /home/carriemo/public_html/wp-content/plugins/gp-premium/elements/class-hooks.php(180) : eval()'d code on line 7."
Would you mind telling me how to correct it?
add_action( 'generate_after_content','social_icons' );
function example_function_name() { ?> <i class="fa-icon-linkedin"></i> <i class="fa-icon-instagram"></i> <i class="fa-icon-facebook"></i> <i class="fa-icon-twitter"></i>
<?php }
Hi there,
Have you loaded FA? If not I would recommend installing this plugin first:
https://wordpress.org/plugins/font-awesome/
Then you can add the HTML below as hook element content:
<i class="fa-icon-linkedin"></i>
https://docs.generatepress.com/article/hooks-element-overview/
Let me know if this helps :)
Font Awesome caused my mobile page speed to crash. I've been using it in the header without the plugins and don't have any issues.
GP itself doesn't load FA by default. So if you are able to use it somewhere else, likely another plugin (page builders) is loading it for you.
If you are using hooks element, then you don't need the add_action part, simply add the HTML part like this:
<i class="fa-icon-linkedin"></i><i class="fa-icon-facebook"></i><i class="fa-icon-instagram"></i>
Make sure you see the second paragraph of my reply :)
https://generatepress.com/forums/topic/social-icons-in-the-blog-footer-using-generate_after_content/#post-1018032
Like this? It seems to match yours, except for including the link, but nothing shows up. It's blank.
<i class="fa-icon-linkedin" aria-hidden="true"></i>
<i class="fa-icon-instagram" aria-hidden="true"></i>
<i class="fa-icon-facebook" aria-hidden="true"></i>
<i class="fa-icon-twitter" aria-hidden="true"></i>
Although blank is probably better than an error code! LOL
Never mind, I got it! The word "icon" has to be removed. It no longer uses it.
It's "fa fa-facebook" as an example, not "fa fa-icon-facebook."
Thank you so much for your help... I appreciate it.
Glad you’ve figured out :)