• Resolved jennnjennjen

    (@jennnjennjen)


    Hi, how do I display my number of subscribers (either via shortcode or some other method)?

    I know that using the subscription form you can configure it to display your subscribers, but I want to display it separate from the subscription form. Thanks!

    • This topic was modified 6 years, 5 months ago by jennnjennjen.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jennnjennjen

    (@jennnjennjen)

    UPDATE: OK I figured it out with some tweaks on the code snipped posted by a user here: https://www.ads-software.com/support/topic/incorrect-number-of-wordpress-followers/

    In case anyone else is interested, the following works but you’ll have to subtract out or disconnect the other subscribers connected via Publicize (twitter, tumblr, etc.)

    <?php 
    $subs_count = get_transient('wpcom_subscribers_total');  
    if (FALSE === $subs_count || 'failed' == $subs_count['status']) {
    	Jetpack:: load_xml_rpc_client();
    	
    	$xml = new Jetpack_IXR_Client(array('user_id' => JETPACK_MASTER_USER,));
    	
    	$xml->query('jetpack.fetchSubscriberCount');
    	
    	if ($xml->isError()) { // error
    		$subs_count = array(
    		'status' => 'failed',
    		'code' => $xml->getErrorCode(),
    		'message' => $xml->getErrorMessage(),
    		'value'=>(isset($subs_count['value']))?$subs_count['value'] : 0,
    		);
    	} else {
    	$subs_count = array(
    	'status' => 'success',
    	'value' => $xml->getResponse(),
    	);
    }
    set_transient('wpcom_subscribers_total', $subs_count, 3600); // cache
    } 
    echo $subs_count[value];?>
    Plugin Support lizkarkoski

    (@lizkarkoski)

    Hi @jennnjennjen

    Thanks for getting in touch and for posting that follow up comment so others can benefit from your findings. Cheers!

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