Sauter la navigation

[Résolu] Custom field to populate YouTube embed code – not working

This support ticket is created Il y a 4 années et 1 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

Ce sujet contient 4 réponses, a 2 voix.

Dernière mise à jour par nickT-2 Il y a 4 années et 1 mois.

Assisté par: Jamal.

Auteur
Publications
#2002013
YouTube Embed Code not working.PNG

Hi,

I'm trying to create a video slider. I have a custom field (single text) for 'YouTube Video ID' and in the view I'm surrounding that field with the embed code. But it's not working. I think the video ID is being lost somewhere in the formatting.

I've attached a screenshot which shows:
- on the left - the custom YouTube ID field
- middle - the code I'm using to create the view
- on the right - the output page displaying a blank video player

To create the embed code I'm using this (which you can see in the middle of the screenshot:

[embedyt]<em><u>lien caché</u></em> field='youtube-video-id' output='raw'][/types][/embedyt]

Would you expect this to create the following embed code?

[embedyt]<em><u>lien caché</u></em>;

Just to test I've added the YT ID field under the embed code which seems to be outputting correctly .. unless it's putting it on a new line which would then break the YT embed code.

Please can I ask if this method of creating the embed code should work? I was also planning on putting certain variables on the end of the url as well. Is there a format setting I should be using? I tried output='raw' but that didn't seem to fix anything.

Thanks
Nick

#2002701

Hello Nick and thank you for contacting the Toolset support.

Can you try the following URL scheme(embed endpoint) instead of the /watch endpoint:

<em><u>lien caché</u></em> field='youtube-video-id' output='raw'][/types]

According to this article, that's the correct URL scheme to use when embedding YouTube videos lien caché

If that does not help, please allow me temporary access to your website to check this closely. Let me know the URL of the page(right of the screenshot). Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#2003485

Hello Nick, and thank you for sharing credentials to your website.

Honestly, I couldn't find what is the issue with the [embedyt] shortcode. The video URL inside of it just doesn't work. Maybe the shortcode is evaluated before the Types shortcode.
So, this works:

<iframe src="<em><u>lien caché</u></em> field='youtube-video-id' output='raw'][/types]" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

While this doesn't:

[embedyt]<em><u>lien caché</u></em> field='youtube-video-id' output='raw'][/types][/embedyt]

And this too doesn't:

[embedyt]<em><u>lien caché</u></em> field='youtube-video-id' output='raw'][/types][/embedyt]

So, I'll suggest to use the iFrame code that I copied from YouTube sharing button instead of relying on the [embedyt] shortcode.

I hope this is a viable solution for you, otherwise, I'll suggest involving the plugin's support team on this too.

#2003497

Hi Jamal,

Ah thank you for having a look. It is a bit of a mystery.

It's unfortunate as this was a plugin that provided the type of features I needed. But having said that I think I've found another plugin which does it's shortcode slightly differently. So instead of:
- two (start and stop) blocks of shortcode e.g. [embedyt] ... [/embedyt]
- it's one block of shortcode e.g. [yourchannel video="YT ID goes here]

This seems to be working OK with the custom Types field pasting it's field content (in this case the Youtube ID) correctly into the shortcode and the shortcode is being processed OK.

In case this is useful for anyone else this plugin is called YourChannel by lien caché

Thanks again for your help.
Cheers,
Nick

#2003499

My issue is resolved now. Thank you!