Support » Plugin: WordPress Share Buttons Plugin – AddThis » Add to Custom Theme Template in WP_Query Loop

  • Resolved jberg1

    (@jberg1)


    Is it possible to add the share buttons to a custom theme template inside a WP_Query loop? I’m trying to use it on a blog page that utilized the_content looping through each entry. I want to have separate share buttons for each entry in this loop.

    Searching on this I found a possible solution, but it doesn’t work.
    <?php do_action( 'addthis_widget', get_permalink(), get_the_title(), 'small_toolbox' ); ?>

    I also tried using <php echo do_shortcode('[addthis tool="addthis_inline_share_toolbox_qab6"]'); ?> But that just repeats the share buttons and they share the blog page itself (instead of each individual post).

    Any other options? Thanks for your help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jberg1

    (@jberg1)

    I did find that they were showing on the single post page. So looking at the code output there I added that to my loop with a small modification to the data-url, which seems to work fine.

    <div class="at-below-post addthis_tool" data-url="<?php the_permalink() ?>"></div>

    But let me know if there is a better way.
    Thanks.

    Plugin Contributor Leland

    (@addthisleland)

    Hi there,

    That is indeed the correct code if you wish to generate multiple share buttons on the same page, each set with a different shared URL.

    Additionally, there’s also other parameters if you wish to control the title (date-title=””) and description (data-description=””) of the shared URL.

    Let us know if you have any further questions!

    Thanks,
    Leland

    Thread Starter jberg1

    (@jberg1)

    Thanks, that’s great info.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add to Custom Theme Template in WP_Query Loop’ is closed to new replies.