• Resolved ymmark0

    (@ymmark0)


    Hey Guys,
    For my site I want to add a widget with the social share buttons, however I need to share the same URL no matter the page the user is on. I.e. I don’t want to share the current page, but a static URL.

    I tried commenting out the section in function.php, however it doesn’t work and is turning into a hack. Is there an easy way to do this?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author micropat

    (@micropat)

    There are a couple of ways to share a specific URL using a WordPress widget:

    1. Add the line add_filter('widget_text', 'do_shortcode'); to your functions.php so that your widgets process shortcodes. Then use the simple AddToAny shortcode in a “Text” widget:
      [addtoany url="https://www.example.com/share-me/" title="Example Title"]
    2. Use the general AddToAny HTML code (with WP-flavored class names) in a “Text” widget like:
      <div class="a2a_kit a2a_kit_size_32 addtoany_list" data-a2a-url="https://www.example.com/share-me/" data-a2a-title="Example Title">
          <a class="a2a_button_facebook"></a>
          <a class="a2a_button_twitter"></a>
          <a class="a2a_button_google_plus"></a>
          <a class="a2a_button_pinterest"></a>
          <a class="a2a_dd"></a>
      </div>

      (You can remove the spaces between the HTML tags to fix any added spacing between icons.)

    Thread Starter ymmark0

    (@ymmark0)

    Thanks for the great reply.
    Do you know if there is a way to make the URL dynamic but not related to the current page.
    So specifically I’m thinking about how I could make the shared URL something like
    https://www.example.com/%5Banother_short_code%5D.

    After a quick glance it doesn’t seem possible to have shortcodes that reference shortcodes.

    Thread Starter ymmark0

    (@ymmark0)

    Just following up, if I do something like this (from your option 2 above)

    <div class=”a2a_kit a2a_kit_size_32 addtoany_list” data-a2a-url=[short_code] etc

    If also doesn’t include the shortcode value.

    Plugin Author micropat

    (@micropat)

    Use PHP in your theme’s files to programmatically customize the shared URL & title, for example:

    <?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) {
        ADDTOANY_SHARE_SAVE_KIT( array(
            'linkname' => 'Example Page',
            'linkurl'  => 'https://example.com/page.html',
        ) );
    } ?>

    (Example from the plugin’s FAQ.)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Share a static link from any page’ is closed to new replies.