Skip to content

Instantly share code, notes, and snippets.

@studiopress
Last active June 28, 2018 17:17
Show Gist options
  • Save studiopress/6866725 to your computer and use it in GitHub Desktop.
Save studiopress/6866725 to your computer and use it in GitHub Desktop.
Pinterest "Pin It" Button.
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
add_action( 'genesis_entry_content', 'sp_custom_pinterest_button' );
<?php
add_action( 'genesis_entry_content', 'sp_custom_pinterest_button', 5 );
function sp_custom_pinterest_button() {
/** Horizontal */
printf( '<div class="pinterest-button"><a href="http://pinterest.com/pin/create/button/?url=%s&media=%s" class="pin-it-button" count-layout="horizontal">Pin It</a><script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script></div>', urlencode( get_permalink() ), urlencode( genesis_get_image( array( 'format' => 'url' ) ) ) );
}
add_action( 'genesis_post_content', 'sp_custom_pinterest_button_after' );
function sp_custom_pinterest_button_after() {
/** Horizontal */
printf( '<div class="pinterest-button"><a href="http://pinterest.com/pin/create/button/?url=%s&media=%s" class="pin-it-button" count-layout="horizontal">Pin It</a><script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script></div>', urlencode( get_permalink() ), urlencode( genesis_get_image( array( 'format' => 'url' ) ) ) );
}
genesis();
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
add_action( 'genesis_entry_content', 'sp_custom_pinterest_button', 5 );
<?php
//* Add Horizontal Pinterest button
add_action( 'genesis_entry_content', 'sp_custom_pinterest_button', 5 );
function sp_custom_pinterest_button() {
printf( '<div class="pinterest-button"><a href="http://pinterest.com/pin/create/button/?url=%s&media=%s" class="pin-it-button" count-layout="horizontal">Pin It</a><script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script></div>', urlencode( get_permalink() ), urlencode( genesis_get_image( array( 'format' => 'url' ) ) ) );
}
genesis();
<?php
//* Add No-count Pinterest button
add_action( 'genesis_entry_content', 'sp_custom_pinterest_button', 5 );
function sp_custom_pinterest_button() {
printf( '<div class="pinterest-button"><a href="http://pinterest.com/pin/create/button/?url=%s&media=%s" class="pin-it-button" count-layout="none">Pin It</a><script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script></div>', urlencode( get_permalink() ), urlencode( genesis_get_image( array( 'format' => 'url' ) ) ) );
}
genesis();
<?php
//* Add Vertical Pinterest button
add_action( 'genesis_entry_content', 'sp_custom_pinterest_button', 5 );
function sp_custom_pinterest_button() {
printf( '<div class="pinterest-button"><a href="http://pinterest.com/pin/create/button/?url=%s&media=%s" class="pin-it-button" count-layout="vertical">Pin It</a><script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script></div>', urlencode( get_permalink() ), urlencode( genesis_get_image( array( 'format' => 'url' ) ) ) );
}
genesis();
/* Pinterest Button
--------------------------------------------- */
.pinterest-button iframe {
margin: 10px 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment