WordPress.org

Ready to get started?Download WordPress

Forums

JW Player for Flash & HTML5 Video
[resolved] [Plugin: JW Player Plugin for WordPress] display video with do_shortcode() php in theme files (10 posts)

  1. Amanda Hawkins
    Member
    Posted 3 years ago #

    I'm trying to add the shortcode into my theme page.php file using

    <?php
    $vid = get_post_meta( $post->ID, 'video', $single = true );
    if ($vid)
    echo do_shortcode('[jwplayer id="'.$vid.'"]');
    ?>

    Under custom field I have 'video' and for the value the video id, 133. Instead of the video it's printing out [jwplayer id="133"]

    I've tried it simply with this code as well and get the same results:
    <?php echo do_shortcode('[jwplayer id="133"]');?>

    Any help is much appreciated, thanks!

  2. sam_jv2
    Member
    Posted 3 years ago #

    I'm having the same issue. I'm using the video in the same manner. It just echos out the shortcode.

  3. shadyvb
    Member
    Posted 3 years ago #

    me 2, same issue happened, so i went to see the source code, to find out it does not use WP native shortcodes, it parses the content for [jwplayer] tags and converts them,using regex.. i wonder why anyone would do that!

    anyway, to work nicely with their script, you should use this:

    echo jwplayer_tag_callback("[jwplayer config=\"Custom Player\" file=\"$media_url\"]")

  4. stonefree
    Member
    Posted 3 years ago #

    shadyvb, thank you for your very timely reply. I was just wrestling with the issue and your reply was the only info I found. Posted mere hours before I had the issue too!

    it parses the content for [jwplayer] tags and converts them,using regex.. i wonder why anyone would do that!

    According to the comments on JWShortcode.php -

    Re-implementation of the WordPress functionality was necessary as it did not support '.'

    What a hassle! I don't get why period support is an issue though. Why does JW Player need that?

  5. Amanda Hawkins
    Member
    Posted 3 years ago #

    @shadyvb - that worked perfectly, you rock!!

    If anyone's curious here's the full code for adding a video & thumbnail:

    <?php
    $vid = get_post_meta( $post->ID, 'video', $single = true );
    $thumb = get_post_meta( $post->ID, 'thumb', $single = true );
    if ($vid)
    echo jwplayer_tag_callback("[jwplayer config=\"Custom Player\" file=\"$vid\" image=\"$thumb\"]"); ?>

    Custom field names are video and thumb with full links to items under value.

  6. JW Player
    Member
    Plugin Author

    Posted 3 years ago #

    Hey guys,

    Yes, it is quite unfortunate that I needed to re-implement the shortcode functionality. It certainly creates more work for me as I need to confirm that it is consistent every time WordPress releases an update.

    In any case, the period is necessary as it allows you to define plugin flashvars in the jwplayer shortcode. For example:

    [jwplayer mediaid="1" plugins="hd" hd.file="my/hd/file.mp4"]

    Let me know if you have any questions.

    Thanks.

  7. MTV
    Member
    Posted 3 years ago #

    oh.amanda

    where should I insert that code?

    Thanks

  8. Amanda Hawkins
    Member
    Posted 3 years ago #

    @MTV - Add it in your theme files wherever you'd like the video to show up.

  9. metavidi
    Member
    Posted 3 years ago #

    Will this code work if I want to place a video inside a single post? I am customizing my theme and I want to be able to place a video (jwpayer plugin) in the header.
    Thanks!

  10. JW Player
    Member
    Plugin Author

    Posted 3 years ago #

    @metavidi,

    I believe oh.amanda's code should work for what you want. Let me know if it doesn't and we can find another solution.

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic