• Resolved Amanda Hawkins

    (@ohamanda-1)


    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!

Viewing 9 replies - 1 through 9 (of 9 total)
  • I’m having the same issue. I’m using the video in the same manner. It just echos out the shortcode.

    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\"]")

    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?

    Thread Starter Amanda Hawkins

    (@ohamanda-1)

    @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.

    Plugin Author JW Player

    (@longtail-video)

    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.

    oh.amanda

    where should I insert that code?

    Thanks

    Thread Starter Amanda Hawkins

    (@ohamanda-1)

    @mtv – Add it in your theme files wherever you’d like the video to show up.

    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!

    Plugin Author JW Player

    (@longtail-video)

    @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.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: JW Player Plugin for WordPress] display video with do_shortcode() php in theme files’ is closed to new replies.