Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to insert Facebook Like Button via functions.php in eleven40 Pro?
Tagged: Eleven40-Pro, Facebook Like, functions.php
- This topic has 4 replies, 2 voices, and was last updated 11 years, 5 months ago by
Chris Moore.
-
AuthorPosts
-
August 21, 2013 at 3:23 pm #58021
Chris Moore
MemberHello there everyone!
I was wondering if someone could please help me to insert the following code at the top of EVERY post in the Eleven40 Pro theme via the functions.php file:
<div class="fb-like fb-post-info" data-href="'. get_permalink() .'" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false"></div>
I would like the Facebook like button this will generate to appear exactly next to (not after) the
entry-meta
(like so):By Lindsey Coulter – Leave a Comment FACEBOOK LIKE
Thanks so much!
Respectfully,
Chris M.
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comAugust 21, 2013 at 3:28 pm #58022Chris Moore
MemberThis is actually the code I want inserted (it doesn't really matter though, as I am really only after the function and/or action I need to use in the
functions.php
):<div class="fb-like" data-href="'. get_permalink() .'" data-width="90" data-layout="button_count" data-show-faces="false" data-send="false"></div>
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comAugust 21, 2013 at 3:59 pm #58039cdils
ParticipantHi Chris,
I highly recommend using the Genesis Visual Hook Guide plugin to see where you can hook in on your pages.If you want to go above the post title, try hooking into either genesis_before_entry or genesis_entry_header.
Unless you're using a custom template, you'll need to add something like this to your functions.php:
add_action ( 'genesis_before_entry', 'my_post_extras' ); function my_post_extras() { if ( ! is_single() ) return; echo 'blah blah'; // add custom output here }
I didn't test that code, so use with caution. 🙂
Carrie
Have you been helped in this forum? Pay it forward and answer someone else’s question. I bet you’ll know the answer to at least one question. 🙂
I host a weekly WordPress-focused podcast called Office Hours. I tweet @cdils.
August 21, 2013 at 4:06 pm #58042Chris Moore
MemberThanks so much Carrie (@cdils)!
Unfortunately, that puts the Like button ABOVE, and only on the post, not the homepage as well (sorry, should have been more clear about that).
I would like it right next to the part that says:
By Lindsey Coulter – Leave a Comment FACEBOOK LIKE
The site in question: http://ReflectOnThis.com
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comAugust 21, 2013 at 5:16 pm #58064Chris Moore
MemberOkay, here's what I did. I basically applied a solution that I have used in the past, which involves creating a shortcode that I can then insert into the appropriate place with the Genesis - Simple Edits plugin.
Here is what I did:
// Add a shortcode for Facebook "Like" insertion ([FB-Like-Shortcode]) function moore_fb_like_shortcode() { if ( is_single () || is_home() ) return '<span class="fb-like fb-post-info" data-href="'. get_permalink() .'" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false"></span>'; } add_shortcode('FB-Like-Shortcode', 'moore_fb_like_shortcode');
Then I just drop
[FB-Like-Shortcode]
where I want it to appear in the Genesis - Simple Edits plugin, and voila!I was hoping to get a simpler, purely
functions.php
solution, so if anyone knows how, please do enlighten me!Reference site: http://ReflectOnThis.com
Thanks again!
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.com -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.