Add new social share buttons (WhatsApp, Tumblr…)

Content Views Pro helps you to show social share buttons easily. By default, you show sharing buttons of Facebook, Twitter, Google +, Linkedin, Pinterest.
To add more social share buttons, please:

  • enable “Social Sharing” in the “Display Settings” tab of the View
    Content Views Pro - social sharing
  • add this code to file functions.php of your active theme:
    // CVPro - Add new social buttons
    add_filter( 'pt_cv_social_links', 'cvp_theme_social_links', 100, 3 );
    function cvp_theme_social_links( $buttons_html, $url, $title ) {
    	$social_link	 = sprintf( 'SHARE_URL_FORMAT=%s', $url );
    	$buttons_html[]	 = sprintf( '<a href="%s" class="%s" target="_blank"></a>', $social_link, esc_attr( 'pt-cv-social-NAME' ) );
    
    	return $buttons_html;
    }
    

    For example, this code will show whatsapp, tumblr and email buttons below each post in View:

    // CVPro - Add new social buttons
    add_filter( 'pt_cv_social_links', 'cvp_theme_social_links', 100, 3 );
    function cvp_theme_social_links( $buttons_html, $url, $title ) {
    	### whatsapp ###
    	$social_link	 = sprintf( 'whatsapp://send?text=%s', $url );
    	$buttons_html[]	 = sprintf( '<a href="%s" class="%s" target="_blank"></a>', $social_link, esc_attr( 'pt-cv-social-whatsapp' ) );
    
    	### tumblr ###
    	$social_link	 = sprintf( 'http://www.tumblr.com/share/link?url=%s', $url );
    	$buttons_html[]	 = sprintf( '<a href="%s" class="%s" target="_blank"></a>', $social_link, esc_attr( 'pt-cv-social-tumblr' ) );
    
    	### Email sharing ###
    	$email_link	 = sprintf( 'mailto:?subject=%s&body=%s', 'Hello, check this post', "$title: $url" );
    	$buttons_html[]	 = sprintf( '<a href="%s" class="%s" target="_blank"></a>', $email_link, esc_attr( 'pt-cv-social-email' ) );
    
    	return $buttons_html;
    }
    
  • add this code to Custom CSS field in Content Views >> Settings page:
    .pt-cv-social-NAME {
    background: url(YOUR_SOCIAL_IMAGE_URL) no-repeat !important;
    background-size: 32px !important;
    }
    
  • replace SHARE_URL_FORMAT, NAME, YOUR_SOCIAL_IMAGE_URL in above code with your values.

Best regards,