- This topic has 17 replies, 4 voices, and was last updated 2 years, 4 months ago by
Ying.
-
AuthorPosts
-
March 26, 2023 at 7:38 am #2582667
martijn
Hi there,
I’m rebuilding an elementor website/blog into GP.
The site contains many blog articles with a Pinterest pin at the end of the article.The posts are enriched with several ACF fields, for example, a Pinterest embed code (pinterest_iframe_url).
Pinterest embed codes have been added in the posts in this field for example:
(https://assets.pinterest.com/ext/embed.html?id=84625458624935670)I also added a Hook with Pinterest javascript to wp-head, display entire site ( <script async defer src=”//assets.pinterest.com/js/pinit.js”></script> )
Now I want to show these pins on the front end via a content template.
But I did not succeed yet. Any idea how to display the (dynamic) pins with embed code on the blog page?Kind regards,
Martin
March 26, 2023 at 8:52 am #2582929David
StaffCustomer SupportHi there,
if those are outputting embeds then it will probably need a shortcode or other method to add the necessary HTML.
Is it possible to see the current site with the pinterest content so i can see what it is exactly ?
March 26, 2023 at 9:48 am #2582988martijn
Hi David
Thanks for your fast reply and support.
I’ve added some examples of the original website.March 26, 2023 at 11:07 am #2583072Ying
StaffCustomer SupportIt looks like it’s been added via a shortcode to your elementor site.
https://www.screencast.com/t/Vi77zXJOBCan you get the shortcode from the site?
March 27, 2023 at 5:50 am #2583933martijn
Hi Ying, David,
Correct. The pin is shown by using a shortcode,
where the embed code is added, per blog, by using ACF.screenshots attached
March 27, 2023 at 8:12 am #2584294David
StaffCustomer SupportYou can try creating your own iFrame shortcode with this PHP Snippet:
function pinterest_embed_shortcode() { $html = ''; // Get Pinterest URL from ACF field $url = get_field( 'your_acf_field_with_pinterest' ); if ( $url ) { $html = '<a data-pin-do="embedPin" href="'.$url.'" data-pin-width="large" ></a>'; } return $html; } add_shortcode( 'pinterest_embed', 'pinterest_embed_shortcode' );
Update the ACF field name. and then you can use
[pinterest_embed]
shortcodeMarch 29, 2023 at 6:36 am #2587123martijn
Hi David,
Thank you for the PHP snippet, but unfortunately,
it doesn’t visually show or embed the pin yet.I’ve updated the ACF field; ‘your_acf_field_with_pinterest’ which becomes ‘pinterest_iframe_url’
and added a shortcode to the template with [pinterest_embed].
In the code, it only shows the link.Am I missing something?
Kind regards,
MartijnMarch 29, 2023 at 5:53 pm #2587991Fernando Customer Support
Hi Martijn,
Can you share the link to the page where you have this added?
March 29, 2023 at 9:07 pm #2588083martijn
Hi Fernando,
I’ve added the link to the page below,
Regards,
MartijnMarch 30, 2023 at 10:48 am #2589296Ying
StaffCustomer SupportCan you try this PHP code for the shortcode instead?
function pinterest_embed_shortcode() { $html = ''; // Get Pinterest URL from ACF field $url = get_field( 'pinterest_iframe_url' ); if ( $url ) { $html = '<iframe src="' . esc_url( $url ) . '" height="552" width="345" frameborder="0" scrolling="no" ></iframe>'; } return $html; } add_shortcode( 'pinterest_embed', 'pinterest_embed_shortcode' );
March 30, 2023 at 12:26 pm #2589418martijn
Thank you Ying,
Yes! Almost there. It only shows a part of the pin (see link).
But I hope that can be solved by tweaking the PHP ?Regards,
MartijnMarch 30, 2023 at 5:11 pm #2589653Ying
StaffCustomer SupportI updated the code:
https://generatepress.com/forums/topic/display-pinterest-embed-code-front-end-acf/#post-2589296I added the width and height attributes in the PHP code, give it another try.
You might need to remove the GB container’s height.
March 30, 2023 at 10:52 pm #2589913martijn
YES! PERFECT!!!
Ying, and offcourse also David & Fernando,
thank you so much for your outstanding support!!!The combination of a perfect product and incredible personal support makes GP stands out.
Forever grateful,Martijn
March 31, 2023 at 10:53 am #2591043Ying
StaffCustomer SupportWe’re very happy to read your reply 🙂
It’s our pleasure!
April 13, 2023 at 6:10 am #2608399martijn
Sorry to bother you again.
Unfortunately, the iframe, with the Pinterest pin is not loading on iOS. On all other devices, Safari desktop, chrome desktop, and mobile, there’s no problem.Any idea how to tackle this?
Kind regards,
MartijnBTW: In Safari (desktop) I noticed a message:
“Refused to execute a script because its hash, its nonce, or ‘unsafe-inline’ does not appear in the script-src directive of the Content Security Policy.” Perhaps this is related to each other. -
AuthorPosts
- You must be logged in to reply to this topic.