Home › Forums › Lite Version › FB Sharer from Masonry Brick
- This topic has 5 replies, 2 voices, and was last updated 5 years, 11 months ago by
Masonry Guy.
- AuthorPosts
- April 20, 2015 at 6:24 pm #4930
recordnj
GuestAt http://www.rifref.com I’d like to share the actual url to the post versus the link to the page that the bricks are rendered. For example…
http://rifref.com/chris-farley/chris-farley-4/ (actual post url) versus http://rifref.com/farley-chris/ (page that all bricks are rendered)
Can you explain how to do that?
share.php code…
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = “//connect.facebook.net/en_US/all.js#xfbml=1″;
fjs.parentNode.insertBefore(js, fjs);
}(document, ‘script’, ‘facebook-jssdk’));<span id=”custom-fb-button”></span>
Thanks!
April 21, 2015 at 4:13 pm #4936Masonry Guy
KeymasterHi,
That code comes from facebook and it auto detects the current page url and send it. As per your requirement, you need custom coded share url for it.
Like ” class=”fb”>IMAGE GOES HERE
Thanks
April 22, 2015 at 1:28 am #4946recordnj
GuestI have it working from facebook when the single.php renders a single post. However, all bricks point to the same page they are rendered on. In other words…
The “Son of a!” brick on http://rifref.com/farley-chris/ (page for all bricks) facebook shares http://rifref.com/farley-chris/ (page for all bricks) when it should be sharing http://rifref.com/chris-farley/chris-farley-3/ (the single post for “Sun of a!”.
How can I have the fb link in the brick point to the correct post?
Thanks!
April 22, 2015 at 4:25 pm #4970Masonry Guy
KeymasterHi,
AS i previously stated above. It takes the url of the current page automatically. We don’t have any control in that code at all. However, you can write custom share url. Here is how to do that.
<a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>" class="fb">Facebook</a>
April 22, 2015 at 4:56 pm #4971recordnj
GuestI think, for me, it ended up being an issue with how WP parses php and html. This worked though…
<?php $turl = get_permalink($post->ID);?>
<span id=”custom-fb-button”>” data-send=”true” data-layout=”icon” class=”fb-share-button”></span>April 23, 2015 at 2:57 am #4977Masonry Guy
KeymasterGlad it is fine for your now.
Thanks
- AuthorPosts
- The forum ‘Lite Version’ is closed to new topics and replies.