Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Dance_a_lot

    (@dance_a_lot)

    Problem solved by using another plugin.

    it would’ve been nice to specify which one you have chosen.

    my quick dirty solution was configuring the share buttons I wanted, copying the generated HTML code, hiding the original share div via CSS then adding a shareThis() function whenever I needed it displayed.

    function shareThis(){
    $currentURL= 'https://'.$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI'];
    echo '<div class="sharethis sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing"><h3 class="sd-title">Share this:</h3><div class="sd-content"><ul><li class="share-print"><a rel="nofollow" class="share-print sd-button share-icon" href="'.$currentURL.'" target="_blank" title="Click to print"><span>Print</span></a></li><li class="share-email share-service-visible"><a rel="nofollow" class="share-email sd-button share-icon" href="'.$currentURL.'?share=email&nb=1" target="_blank" title="Click to email this to a friend"><span>Email</span></a></li><li class="share-twitter"><a rel="nofollow" class="share-twitter sd-button share-icon" href="'.$currentURL.'?share=twitter&nb=1" target="_blank" title="Click to share on Twitter" id="sharing-twitter-56"><span>Twitter</span></a></li><li><a href="#" class="sharing-anchor sd-button share-more"><span>More</span></a></li><li class="share-end"></li></ul><div class="sharing-hidden"><div class="inner" style="overflow: hidden; left: 654.75px; top: 799.6875px;"><ul><li class="share-linkedin"><a rel="nofollow" class="share-linkedin sd-button share-icon" href="'.$currentURL.'?share=linkedin&nb=1" target="_blank" title="Click to share on LinkedIn" id="sharing-linkedin-56"><span>LinkedIn</span></a></li><li class="share-google-plus-1"><a rel="nofollow" class="share-google-plus-1 sd-button share-icon" href="'.$currentURL.'?share=google-plus-1&nb=1" target="_blank" title="Click to share on Google+" id="sharing-google-56"><span>Google</span></a></li><li class="share-end"></li><li class="share-facebook"><a rel="nofollow" class="share-facebook sd-button share-icon" href="'.$currentURL.'?share=facebook&nb=1" target="_blank" title="Share on Facebook" id="sharing-facebook-56"><span>Facebook</span></a></li><li class="share-pocket"><a rel="nofollow" class="share-pocket sd-button share-icon" href="'.$currentURL.'?share=pocket&nb=1" target="_blank" title="Click to share on Pocket"><span>Pocket</span></a></li><li class="share-end"></li><li class="share-end"></li></ul></div></div></div></div></div>';
    }

    and this css:

    .sharedaddy {display: none;} /* hide default sharing widget*/
    .sharedaddy.sharethis {display: block; } /* show my sharing widget */
    .sharedaddy.sharethis .inner {display: none}

    Of course the plugin needs to be activated for all the page types I want it visible in – so it loads the required CSS and js – which I was too lazy to load separately – though that would be a bit more elegant.

    Instead a function (useful in a template) one could pretty easily add a shortcode.

    Alright, I’ve been trying to do the same thing, and I finally found a solution to this. Hacking it is definitely fun, but this is a quick logical way to place the code where you want.

    Thanks to andersbalari:

    <!-- remove the plugins' version of the sharing icons -->
    <?php remove_filter( 'the_content', 'sharing_display', 19 ); ?>
    <?php remove_filter( 'the_excerpt', 'sharing_display', 19 ); ?>
    
    <!-- this is the function to display the social icons you picked in the admin -->
    <?php echo sharing_display(); ?>
    
    <!-- display the content -->
    <?php the_content(); ?>

    Explained by andersbalari here https://www.ads-software.com/support/topic/custom-placement-of-jetpackssharedaddys-sharing

    Isn’t there a simple [sharethis] shortcode that can be called? I tried to wrap my head around this… but failed ??

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Shortcode’ is closed to new replies.