• Hi there. My site is https://www.acenavigates.com and I am using the PenciDesign “Soledad” theme. Which, to be honest, is absolutely brilliant. I’ve pretty much got everything set up, but I’ve run into quite the annoying problem.

    In the Soledad theme, when you click on the Pinterest icon at the bottom of the post, it takes you to the Pinterest pin page. But the problem is, it uses my featured image as the ONLY option for pinning. This is NOT ideal because my featured images need to be quite horizontally skinny to fit the aesthetic of my featured slider on my homepage. Pinterest is much better using vertical images. And anyways, I’m sure the user would appreciate the variety of selection.

    I’ve gotten as far as locating the function in Soledad’s .php file. This is what it says.

    $pinterest_image = wp_get_attachment_url(get_post_thumbnail_id( $post->ID ));

    Now I understand that get_post_thumbnail_id( $post->ID )) is the FEATURED IMAGE being retrieved as the image to be used, if I’m not mistaken.

    But what can I replace this with so that the user is given options as to which image to use as the pin?

    I’ve searched all over the web the past day and a half, and spent hours in the wordpress codex documentation to no avail. There are similar inquiries here on the forum, but none of them solve my issue.

    I would definitely appreciate your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I suspect the solution is much more involved than you imagine. Server side script is not going to be very useful if you need user interaction. You need to develop a user interface that allows the user to select the desired image. This would be done client side with JavaScript or jQuery. It should be fairly simple to get all post images with jQuery.

    You’d also need to hook into whatever the theme currently does to do a pin in order to add the selected image to the data being sent. By default it’ll be the featured image, but your script could replace this with the user selection. It could also insert a generic placeholder image in place of the featured image in case the user fails to make a selection.

    In order to pull this off, you would normally want to create a child theme, but I suspect your theme is already installed as a child of a parent framework. This makes your task more difficult because you should strive to effect all changes through a plugin. Directly hacking the theme’s code is strongly discouraged because you will lose all of your changes when the theme is updated.

    It appears the featured image is included as an URL parameter in the pinterest link, so your approach might be as follows:

    The pinterest link needs to have an onclick attribute added to launch the image selection dialog. Depending on how the link is inserted, there may be an filter that can be used. It’ll probably be easier to simply add it to the theme’s template if you’re willing to re-add it every time the theme is updated. It can also be inserted with JavaScript after the page loads.

    When the onclick event fires, the first thing your script would do is stop the default action so the link is not followed. Then the image selection UI is launched.

    How the image selection UI works is up to you and your coding skills. You could generate a grid of thumbnails, or let the user select images directly from the page similar to how the browser’s inspector tool works to select page elements to inspect. There’s likely several other possibilities.

    Once the image is selected, a new pinterest link URL is constructed. You could start with the existing href URL in the theme’s pinterest link, replacing the featured image parameter with the user selected image URL. Your script then follows this new URL to pin the post.

    hello, this is a test.

    So, sorry i interupted you, i can still post, just not under the Next Gen topic…….

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘I don't want Pinterest to automatically select post's "featured image"’ is closed to new replies.