Pregunta

Is it possible to include multiple images in the media parameter for a Custom Pinterest button?

For instance, I know ow to include one specific image:

<?php $pinterestimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>
<a href="http://pinterest.com/pin/create/button/?url=<?php echo urlencode(get_permalink($post->ID)); ?>&media=<?php echo $pinterestimage[0]; ?>&description=<?php the_title(); ?>" class="pin-it-button" count-layout="vertical">Pin It</a>

but let's say I have a image carousel in a custom post type. I want the ability to pin each image in the carousel. I have already queried the images for the carousel, so it's just a matter of the syntax of encoding them into the url properly. This didn't work:

<a href="http://pinterest.com/../../?url=<?php echo urlenco../&
media=<?php echo $largeImages; ?>&../../>Pin It</a>

where $largeImages is a query of all attachments in the post.

¿Fue útil?

Solución

Figured this out. It's quite simple, but not explicitly stated in the docs. Just remove the media tag altogether and it will pull images from the post.

<a href="http://pinterest.com/pin/create/button/?url=<?php echo urlencode(get_permalink($post->ID)); ?>&description=<?php the_title(); ?>" class="pin-it-button" count-layout="vertical"><span><img width="29" height="29" src="<?php bloginfo('template_url'); ?>/img/socialButtons/share/icons/24/pinterest.png" alt="Twitter" /></span></a>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top