• Resolved HorrorUK

    (@horroruk)


    I am trying to add a custom field to show a video post, but am having a problem.

    The original embed code is:

    <object width="583" height="328"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.openfilm.com/flvplayer5.swf?link=http://www.openfilm.com/player/video/?&video_id=21440</strong></em>&lang=en_us&sort_id=1&color1=0xa2a2a2&color2=0x3e3e3e"/><embed src="http://www.openfilm.com/flvplayer5.swf?link=http://www.openfilm.com/player/video/?&video_id=21440</strong></em>&lang=en_us&sort_id=1&color1=0xa2a2a2&color2=0x3e3e3e" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="583" height="328"></embed></object>

    For the custom field, I am using Video and am then using the following code:

    <?php $image = get_post_meta($post->ID, 'Video', true); ?>

    I have then replaced 21440 with <?php echo $video; ?>

    All I am getting though is the video screen as though I had added a non-existent video ID, though I do have the custom field set up on my test post.

    You can see what I mean here.

Viewing 7 replies - 1 through 7 (of 7 total)
  • For the custom field, try this instead.

    <?php if( get_post_meta($post->ID, "Video", true) ): ?>
      <?php echo get_post_meta($post->ID, "Video", $single = true); ?>
      <?php else: ?> There is no Video
      <?php endif; ?>

    Oh! sorry, disregard my last post. I thought you were calling the whole video.

    Thread Starter HorrorUK

    (@horroruk)

    no problem, thanks for trying to help out 🙂

    Here, try this.

    <?php if( get_post_meta($post->ID, "Video", true) ): ?>
    
    <object width="583" height="328">
    <param name="allowfullscreen" value="true" />
    <param name="allowscriptaccess" value="always" />
    <param name="movie" value="http://www.openfilm.com/flvplayer5.swf?link=http://www.openfilm.com/player/video/?&video_id=<?php echo get_post_meta($post->ID, "Video", $single = true); ?></strong></em>&lang=en_us&sort_id=1&color1=0xa2a2a2&color2=0x3e3e3e"/>
    <embed src="http://www.openfilm.com/flvplayer5.swf?link=http://www.openfilm.com/player/video/?&video_id=21440</strong></em>&lang=en_us&sort_id=1&color1=0xa2a2a2&color2=0x3e3e3e" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="583" height="328"></embed>
    </object>
    <?php else: ?>
    <?php endif; ?>

    Thread Starter HorrorUK

    (@horroruk)

    Thanks for that, works perfectly :o)

    I am glad you sorted out. However, I have re-edited the code. There was an open tag on the object parameter. You may change it to the new fixed code.

    <?php if( get_post_meta($post->ID, "Video", true) ): ?>
    <object width="583" height="328">
    <param name="allowfullscreen" value="true" />
    <param name="allowscriptaccess" value="always" />
    <param name="movie" value="http://www.openfilm.com/flvplayer5.swf?link=http://www.openfilm.com/player/video/?&video_id=<?php echo get_post_meta($post->ID, "Video", $single = true); ?></strong></em>&lang=en_us&sort_id=1&color1=0xa2a2a2&color2=0x3e3e3e"/>
    <embed src="http://www.openfilm.com/flvplayer5.swf?link=http://www.openfilm.com/player/video/?&video_id=21440</strong></em>&lang=en_us&sort_id=1&color1=0xa2a2a2&color2=0x3e3e3e" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="583" height="328"></embed>
    </object>
    <?php else: ?>
    <?php endif; ?>

    Thread Starter HorrorUK

    (@horroruk)

    Thanks

    WP has a great community :o)

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom Field Problem’ is closed to new replies.