• Resolved ricun

    (@ricun)


    I have a page with 3 instances, two are lists of custom post types and the other is in a modal with a video, the ones in the list are inside of the ‘while’ because they have to be shown for every post. All the share options just repeat the ones from the last post.
    I used both formats html/js and is the same result.

    I can’t link the page, which is in a test server because the site is for a client and it will be launch soon.

    https://ww.wp.xz.cn/plugins/add-to-any/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter ricun

    (@ricun)

    EDIT: if I examine the elements with firebug the content in the scripts (url/title) are correct for every post, the problem is when I share/tweet

    Plugin Author micropat

    (@micropat)

    It’s not yet clear how you’re implementing AddToAny within the site. If you can provide a live example, or a Gist (or similar) of the HTML source, that could help folks here help you.

    Thread Starter ricun

    (@ricun)

    <div>
    <?php
    $args = array(
    ‘post_type’ => ‘my_post_type’,
    ‘posts_per_page’ => 3,
    );
    $query1 = new WP_Query($args);
    while ($query1->have_posts()) : $query1->the_post();
    $postarray = array(
    ‘title’ => get_the_title(),
    ‘share’ => get_the_permalink()
    );
    ?>
    <div class=”col-md-3″>
    <div>
    <?php the_content() ?>
    <div class=”a2a_kit social-share”>

    <i class=”fa fa-twitter”></i>
    <i class=”fa fa-facebook”></i>
    <span><p class=”share-text”>Share</p></span>

    </div>
    <script type=”text/javascript”>
    a2a_config.linkname = <?php echo $postarray[‘title’] ?>;
    a2a_config.linkurl = <?php echo $postarray[‘share’] ?>;
    a2a.init(‘page’);
    </script>
    </div>
    </div>
    <?php
    endwhile;
    wp_reset_postdata();
    ?>
    </div>

    That is one of the sections.
    I have the <script type=”text/javascript” src=”//static.addtoany.com/menu/page.js”></script>
    after the first script and is out of a repeating structure

    Thread Starter ricun

    (@ricun)

    EDIT: I have always used like this, and it works fine if there is only one instance like in the single.

    Plugin Author micropat

    (@micropat)

    In this unique case, I’d recommend using data-a2a- attributes to set the shared URL & title:
    https://www.addtoany.com/buttons/customize/single_button_specific_page

    <div class="a2a_kit a2a_kit_size_32 a2a_default_style social-share" data-a2a-url="https://example.com/page.html" data-a2a-title="Example Page">
    <a class="a2a_button_twitter fa fa-twitter"></a>
    <a class="a2a_button_facebook fa fa-facebook"></a>
    <a class="a2a_dd share-text"></a>
    </div>

    If you’re using the plugin, it already loads page.js optimally, so there’s no need to load it again.

    Thread Starter ricun

    (@ricun)

    Fixed, the problem was my html structure:
    My structure was

    <div class="a2a_kit social-share">
     <ul>
      <li>
        <a class="a2a_button_twitter"><i class="fa fa-twitter"></i></a>
      </li>
      <li>
        <a class="a2a_button_facebook"><i class="fa fa-facebook"></i></a>
      </li>
     </ul>
    </div>

    I removed the ul/li

    <div class="a2a_kit social-share">
      <a class="a2a_button_twitter"><i class="fa fa-twitter"></i></a>
      <a class="a2a_button_facebook"><i class="fa fa-facebook"></i></a>
    </div>

    It is working fine now.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Multiple instance repeats the last title/url’ is closed to new replies.