• Can I pass a parameter to a like button to have it keep a separate count for an element?

    For instance, I use a CPTs that sometimes gets reused in posts. I would like a separate count for each CPT that appears on a new post.

    For instance, on the website above, in each issue, each clickable ad (the CPT) has its own Like button. The one with the most likes gets a special designation (red sparkles). The ads that appear in more than one post tend to get the most Likes, and I would like that to be treated separately in each issue.

    Is that clear at all?

    Here is the code in my CPT template:

    <div class="upvote">
        <?php echo do_shortcode(
            '[wp_ulike for="thing" id="' . get_the_ID() . 
            '" style="wpulike-twitter"]'); ?>
    </div><!-- .upvote -->

    So I guess a question that I’m asking is this: Is the id linked to the CPT or is it just an arbitrary id that gets looked up in the ULike database? Does it expect an integer?

    Could I change this code to:

    <div class="upvote">
        <?php echo do_shortcode(
            '[wp_ulike for="thing" id="' . $issueNum . get_the_ID() . 
            '" style="wpulike-twitter"]'); ?>
    </div><!-- .upvote -->
    • This topic was modified 4 years, 7 months ago by Wes Modes.
    • This topic was modified 4 years, 7 months ago by Wes Modes.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter Wes Modes

    (@wmodes)

    After a test, it looks like the count is associated with an arbitrary id. So yes, it appears that I can add an arbitrary number before or after the id and still have it work.

    Now, if I can only figure out how to get the id of the outer post that my CPT is inserted into.

Viewing 1 replies (of 1 total)
  • The topic ‘Pass parameter for new count?’ is closed to new replies.