Tagged: #, social share buttons
-
AuthorPosts
-
April 6, 2018 at 3:41 am #937986
Hi guys,
I know this is a really long shot, but I just want to make sure there isn’t a way to achieve this before I write it off entirely…
I’ve created a number of guest photo galleries inside a tabbed slider, and I’d really like our guests to be able to share a link directly to their own gallery via the social share buttons (in other words, the link to their specific tab containing their gallery). Here’s an example of a gallery that I’d like them to be able to share:
Now I know that WordPress and PHP in general can’t query the full link including the fragment or named anchor (# part at the end), because the anchor is only added to the URL on the client side, not the server side, and for that reason your [permalink] argument or WordPress’s get_permalink() function, only fetches the part before the anchor (you’d need Javascript to get around this), however I was wondering whether you clever guys can help me come up with an additional function that would fetch the named anchor (#) part of the above link from your tabbed slider directly, and then assemble the final share URL by adding the respective tab slug to the final share URL.
So we’d end up with a new function to assemble the permalinks like this:
$replace['permalink'] = !isset($this->post_data['permalink']) ? get_permalink() + # + Some Function to Query the named anchor in the Tabbed Slider : $this->post_data['permalink'];
At the moment I’ve got a unique instance of the share buttons in each tab, so perhaps we can address each instance of the social share buttons individually where the tab slug (anchor) is already known to that instance of the social share buttons, or we only need one instance of the social share buttons on the guest galleries page, and we query the tab’s slug (anchor) at the time of assembling the share URL in real time.
Does any of this sound doable, or am I wasting my time and should I abandon the idea?
I imagine others might find this useful and if it works, I think it could be applied to a number of other uses where your short codes generate a # anchor that can be addressed via a custom function.
Thank you, I appreciate any assistance with this.
Brendon
PS: Hat off to Kriesi and the fantastic team he’s put together for developing and supporting such an awesome framework and theme. You guys can really be proud of what you’ve built over past 4 or 5 years. This theme is the best investment in WordPress I ever made… and just keeps getting more and more powerful with every major update…
- This topic was modified 6 years, 8 months ago by inMotionGraphics.
April 10, 2018 at 8:30 am #939699Hey inMotionGraphics,
Thank you for using Enfold.
I’m not sure if that’s possible but you can try to create a custom script (javascript or jQuery) that alters the href attribute of the share buttons. You can then append the window.location.hash or the url fragment to the value of the href attribute or url. Or just append the href attribute value of the tab section title to the share link url or href value. This seems to be doable because the url query of each share links is at the very end of the pattern.
Best regards,
IsmaelApril 13, 2018 at 8:50 am #941340Thanks for getting back to me on this Ismael.
So is there no way to query the slug of the tab directly via a function added to functions.php? That’s not a bad suggestion to use the tab section title to determine the slug with a bit of manipulation, but would be easier to just query the slug directly if there were such a function. Of course even if I use the title of the tab, how would I query the title of each tab? Do you guys have a function for this that I can use?
A custom script would definitely be doable, but I was hoping to avoid that, as I imagine a query in my functions.php file would be easier to maintain.
Thanks.
Brendon
April 16, 2018 at 4:07 am #942394Hi,
So is there no way to query the slug
There’s no built-in function for that, unfortunately, so you won’t be able to use the social share filter. This will require some modification directly in the frontend.
Best regards,
IsmaelMay 3, 2018 at 2:13 pm #950781Did you even fix this? Having the same issue :)
Maybe an external plugin that works?May 4, 2018 at 8:58 pm #951851Hi,
Unfortunately, it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However, if it’s really important for you to get this done, you can always hire a freelancer to do the job for you :)
Best regards,
BasilisMay 5, 2018 at 6:16 am #952021Hi Pixelbits,
Just to add to what Basilis said above, I wanted to point out that there is nothing wrong with the theme, and the way the theme currently works is the right way and doesn’t need fixing so to speak. There’s nothing broken there. The reason for this is because PHP and WordPress can’t query the fragment or anchor (# part of the URL) because the anchor is changed on the client side, not the server side. So you’ll need some fancy Javascript trickery to query the # part of the URL, or you need to find another way to predict what the anchor will be on the server side, which is the method I am interested in exploring. In particular, I want to use the title or slug of my tabs (because I know what these are, and should be able to query them with a custom function) to modify the share URL via the social share filter.
However I haven’t had a chance to work on this yet, but if I do develop a solution, I will definitely post how I did it here.
Also keep in mind that under normal circumstances, you actually wouldn’t want the theme’s social media sharing feature to include the anchor of a URL, as you’d prefer the clean page URL to be shared and promoted. So this is a very specific use case that we’re looking at adding.
Brendon
May 7, 2018 at 9:43 pm #952909Hi,
Thank you for your clarification, it is much appreciated.
Best regards,
Basilis -
AuthorPosts
- You must be logged in to reply to this topic.