• Resolved xbladerunner

    (@xbladerunner)


    I haven’t been able to figure out how to share search results. I have several pages with community resource links on them and a search bar. I can share the pages just fine using AddToAny. However, when someone searches for a specific word on one of those pages, the search results show up on a separate page with AddToAny functionality, BUT when that page with the search results is shared, only the original resource page is shown as the link shared… not the search results page. The url in the browser bar changes to reflect the search results page (i.e., the new url in the browser includes the search string), but for some reason that url is not the one used by AddToAny as the link to share. Can anyone help me sort this out? My initial impression is that I’ll need to add something to the “additional javascript” area, but I haven’t been able to figure out what to add yet, to get the search results string to show up as the shared link. AddToAny otherwise works great with all the other pages, no issues at all, just when sharing search strings.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter xbladerunner

    (@xbladerunner)

    I was able to eventually figure this out on my own, I’m adding my solution here in case anyone else gets stuck on the same issue. I searched google for “how to get the current url with javascript”, and learned that window.location.href is the code I needed to add. I wasn’t certain however where to put it until I looked at this page provided by the addtoany developers: https://www.addtoany.com/buttons/customize/wordpress/events
    On that page it provides an example under the section “Modifying the Share”, of some code to add to the “additional javascript” section of the addtoany settings page (goto admin, settings, addtoany, scroll down to additional javascript).
    I replaced the existing template in that area with the code provided by the developers and saved it. The result still wasn’t what I needed until I switched out the part of the code that says new_url = old_url + hash_pi; with new_url = window.location.href;
    That did the trick. Now when someone searches our website, if the search results page has addtoany active, the actual search results can be shared, instead of just the search page. I’m not sure why this isn’t the default behavior of the plugin, maybe it is and my site is just uniquely not allowing this behavior without the tweak, but whatever the case, I hope the solution here is helpful to someone.

    Plugin Author micropat

    (@micropat)

    Very workable solution, glad you found AddToAny’s documentation. ??

    AddToAny is correctly sharing the canonical URL by default — it’s actually the Link Library plugin’s search block (or shortcode) used on that page that has no effect on the canonical URL of its own search results.

    You might request that feature/fix from the author of the Link Library plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to Share Search Results?’ is closed to new replies.