I have a field inside the WordPress admin area, in the post-new.php section. I use the latest version of WordPress, as well as the Advanced Custom Fields plugin so that I can write out this field in header.php.
I use this field for the og:video tag, so that I can easily output a secure video url.
The problem is, the default field value is https, and so that I can recall it, the video url must always start with https.
When I click the publish button, the database saves this value, such that the og secure url in a blank state will only be https.
For example:
<meta property="og:video" content="http://ift.tt/1UhYFTq" />
This is a problem, because I don't want a blank video in the post for Facebook.
As such, I need to check two things in the header:
- Firstly: is the field empty?
- Secondly: Are there any characters in the string after
https://?
If both the conditions are met, the code should output the url.
Current php code:
$video_url = get_field('video_url');
if (isset($video_url)) {
$meta1='<meta property="og:video:type" content="application/x-shockwave-flash" />';
$skinURL="http://ift.tt/1UhYDLp";
$meta2=' <meta property="og:video" content="http://ift.tt/1UhYFTs'.urlencode($video_url).'&autostart=true&skinName=newtube&skinURL='.urlencode($skinURL).'" />';
echo $meta1;
echo $meta2;
}
Aucun commentaire:
Enregistrer un commentaire