WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Post Share Count

Show twitter and facebook share count.

How to add html wrapper or some css class to counter and/or display counter as link?

Use array as argument with keys before_ and after_ prefix and social link name, here is example how to add @via parameter twitter sharing link:

<?php
$share_args = array(
    'before_twitter' => '<span class="share-link"><a href="https://twitter.com/intent/tweet?text=' . urlencode(get_the_title()) . '&url=' . urlencode(get_permalink()) . '&via=' . urlencode('your-twitter-name') . '" rel="nofollow" target="_blank"><span class="genericon genericon-twitter"></span> ',
    'after_twitter' => '</a></span>',
);
the_post_share_count( $share_args );
?>

Also you can add changes to functions.php:

function your_theme_post_share_count_services( $services ) {
    $services['twitter']['before'] = '<span class="share-link"><a href="https://twitter.com/intent/tweet?text=%title%&url=%url%&via=' . urlencode('your-twitter-name') . '" rel="nofollow" target="_blank"><span class="genericon genericon-twitter"></span> ';
    return $services;
}
add_filter('post_share_count_services', 'your_theme_post_share_count_services');

How to limit list of social networks? (or "I want only twitter counter")

Add show_only parameter:

<?php
$args = array('show_only' => array( 'twitter', 'facebook' ));
the_post_share_count($args);
?>

Also you can do it in functions.php:

function your_theme_post_share_count_services( $services ) {
    unset( $services['facebook'] );
    unset( $services['pinterest'] );
    unset( $services['googleplus'] );
    unset( $services['linkedin'] );
    return $services;
}
add_filter('post_share_count_services', 'your_theme_post_share_count_services');

Requires: 3.0 or higher
Compatible up to: 3.6.1
Last Updated: 2014-3-16
Downloads: 1,012

Ratings

5 stars
5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1