Support » Plugin: AddToAny Share Buttons » Custom button not sharing manual link

  • Resolved Kevin


    Hi guys,

    On my homepage, I am trying to set up a manual share button which links to a specific post on my site. I included the following code in my homepage template:

    <?php if( function_exists('ADDTOANY_SHARE_SAVE_KIT') ) {
    ADDTOANY_SHARE_SAVE_KIT( array("linkname" => "Example Page", "linkurl" => "") );
    } ?>

    The problem is that it is not providing a popup window to share the page provided in the “linkurl”, but instead it is taking me here trying to link to the main website.

    I would provide a url to the website but its on a local server. Any ideas?

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


    Most likely AddToAny’s required script is not loading. Where are you placing this code and in what theme?

    Hey thanks for responding,

    I cannot find any js in my plugin folder, maybe that has something to do with it? I downloaded it directly from the repository so don’t know if that’s it.

    I am placing this code within a loop that queries some fields from the most recent post of a custom post type. Here is the full code:

    <div id="top">
    			<header id="latest-message"><h2>LATEST MESSAGE</h2></header>
    			<?php 	$args = array(
    								'post_type' => 'messages',
    								'posts_per_page' => 1
    					$posts = get_posts( $args );
    					foreach ( $posts as $post ) : setup_postdata( $post );
    						$speaker = get_field( 'msg_speaker' );
    						$date = get_field( 'msg_date' );
    						$title = get_the_title();
    						$url = get_field( 'msg_url' );
    			<div id="message-content">
    				<p class="info"><strong><?php echo $speaker; ?></strong>
    				<span class="date"><?php echo $date; ?></span>
    				<a href="<?php echo $url; ?>" class="title"><?php echo $title; ?></a></span>
    				<div id="social">
    					<a href="<?php echo $url; ?>" class="listen"><img src="<?php echo $template; ?>/images/home-social-bg.jpg" style="margin-left: -11px;" alt="LISTEN"></a>
    					<a href="<?php echo $url; ?>" download="<?php $title; ?>" class="download"><img src="<?php echo $template; ?>/images/home-social-bg.jpg" style="margin-left: -85px;" alt="DOWNLOAD"></a>
    					<?php if( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) {
    							ADDTOANY_SHARE_SAVE_KIT( array( 'linkname' => 'Example Page', 'linkurl' => '' ) );
    					} ?>
    			<?php	endforeach;
    			wp_reset_postdata(); ?>

    This is a custom theme based off of underscores. It has both wp_head() and wp_footer() where they belong. Any clue?

    Plugin Author micropat


    This works on other Underscores themes, so definitely keep troubleshooting your custom theme. First, make sure it’s working on the default TwentySomething or default Underscores theme. Also, does the plugin’s default sharing placement work with your custom theme?

    The asynchronously loaded JS is //

    Viewing source, you should see a block of AddToAny code in your <head> for that.

    In your footer area, you should should see something like:

    {title:'Example Page',url:''};

    I’m sorry, I only checked the files, the scripts actually are loading in the head and footer. The scripts were actually loading. After I saw that I explored the actual code and the issue had to do with the local cache variables. I have a custom upload directory, and when I checked the plugin correctly added an addtoany folder to that directory, but maybe that was causing issues? As soon as I turned off the use local cache option everything started working fine.

    How exactly does the caching option work and can you tell what was going wrong?

    Plugin Author micropat


    The old local script caching option was fixed in a recent release; however, most websites should not use this option because AddToAny’s asynchronously-loaded script tends to load immediately in a visitor’s browser thanks to AddToAny’s client-side caching. With the local cache option enabled, visitors have to unnecessarily re-load AddToAny, which is slower on most websites. It’s best to leave this one unchecked.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom button not sharing manual link’ is closed to new replies.