WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] pinterest custom images, description not working correctly

[Resolved] pinterest custom images, description not working correctly

  • lotsamottsa

    @lotsamottsa

    Hello, I’m trying to allow users to select which image they want to pin in the same way the “pin it” button works in the browser toolbar. Here’s the example. You’ll see that everything is working great, except after choosing an image, the description field outputs this:

    <?php { echo the_title(); } ?>

    I am using the following javascript code for my custom button:
    <a href='javascript:void((function()%7Bvar%20e=document.createElement(&apos;script&apos;);e.setAttribute(&apos;type&apos;,&apos;text/javascript&apos;);e.setAttribute(&apos;charset&apos;,&apos;UTF-8&apos;);e.setAttribute(&apos;src&apos;,&apos;http://assets.pinterest.com/js/pinmarklet.js?r=&apos;+Math.random()*99999999);document.body.appendChild(e)%7D)());'></a>

    My main images are placed on the pages through custom fields… and each image does have a title and description. When I use the php code, as on this page I do get the description, but I don’t want to automatically pull in the thumbnail.

    Any input as to how I can combine these two so that 1. Users can choose which image to pin and 2. the description is pulling in correctly, will be greatly appreciated.

    Thanks!

Viewing 1 replies (of 1 total)
  • lotsamottsa

    @lotsamottsa

    Nevermind I found a solution, if anyone else is having the same issue! My custom field code had this:

    echo '<img src="' . $snapshot . '" alt="<?php { echo the_title(); } ?>" />';

    I removed the alt tag and now the pinterest functionality displays the title correctly.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] pinterest custom images, description not working correctly’ is closed to new replies.
Skip to toolbar