I posted a discussion on CSS-Tricks the other day. Explaining that my Videos were not displaying on my Video page from my custom post type that I created using this tutorial. I thought I fixed the issue but it turns out the issue wasn't resolved.

Anyway, so I thought maybe the way I setup my CPT/Fields were messing things up. So I found another tutorial and redid the CPT and Fields, here is the new code.

I was able to get my Video ID field to save, but when I select "Youtube" or "Vimeo", then save, it just goes back to it's default option "Select". So when I view my page the container where the video should be placed is blank.

I am new to all of this Wordpress PHP so I have no idea if the select menu code is correct...or whatever the issue is. I'd appreciate any help to find the cause of this.

EDIT// After editing this line:

$ret .= '<script>jQuery(document).ready(function(){ jQuery("#videotype").val(' . get_video_field("videotype") . ') });</script></div>';

to this:

$ret .= '<script>jQuery(document).ready(function(){ jQuery("#videotype").val("' . get_video_field("videotype") . '") });</script></div>';

The Selected Video Type can now be saved, but my issue with a blank container remains... I pasted the PHP section which should display the video in this pastebin.

1 Answer 1


This is a javascript issue. on line 52:

$ret .= '<script>jQuery(document).ready(function(){ jQuery("#videotype").val(' . get_video_field("videotype") . ') });</script></div>';

In this specific bit:

.val(' . get_video_field("videotype") . ')

The value isn't quoted, so it's trying to reference a variable named youtube or vimeo, which doesn't exist, instead of a literal text value.

If you add quotes it'll work, note the addition of double quotes before and after the single quotes:

.val("' . get_video_field("videotype") . '")

So the whole line will be:

$ret .= '<script>jQuery(document).ready(function(){ jQuery("#videotype").val("' . get_video_field("videotype") . '") });</script></div>';

EDIT- In your template, these two lines:

$videotype = get_post_meta($post->ID, 'Video Type', single);
$videoid = get_post_meta($post->ID, 'Video ID', single);

Should be:

$videotype = get_post_meta($post->ID, 'videotype', true);
$videoid = get_post_meta($post->ID, 'videoid', true);
  • Thank you for your time, and for explaining the issue. I tried adding the line, and now the selected video type gets saved but on the front-end my video still doesn't appear...I have a feeling the issue might be in the php code within my video's template. I will edit my question and add the php into a pastebin...if you don't mind looking through it?
    – keilowe
    Commented Jul 4, 2013 at 2:11
  • see edit above.
    – Milo
    Commented Jul 4, 2013 at 2:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.