Home Forums Plugin Support WP User Frontend Pro You Tube Link

This topic is: resolved

Tagged: 

This topic contains 14 replies, has 6 voices, and was last updated by  Tareq Hasan 5 years, 11 months ago.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #4523

    LJA32118
    Participant
    Post count: 7

    I created a URL field for a link to a YouTube Video. It displays the text of the link when I include this in the single.php

    < ?php echo get_post_meta( $post->ID, ‘you_tube_link', true ); ?>

    How can I get to embed and auto display the video rather than just show the text of the link?

    #4525

    paperweight
    Participant
    Post count: 122

    Check this page:
    http://codex.wordpress.org/Embeds

    Maybe wrap it in shortcode to display? For example does this work, or something like it?
    [embed]< ?php echo get_post_meta( $post->ID, ‘you_tube_link’, true ); ?>[/embed]

    #4526

    LJA32118
    Participant
    Post count: 7

    Tried that and it prints out the following:

    [embed]http://www.youtube.com/watch?v=f3tQLBLPSBI[/embed]

    and on those that don't have a YouTube link it prints out:

    [embed][/embed]

    I checked out that WordPress Page plus about every other page about embedding a YouTube video in the single.php

    It works if it is included in the Post Body but not as a field unto itself.

    #4542

    paperweight
    Participant
    Post count: 122

    Then I'm unclear too — maybe try to make sure it's wrapped in the Loop? I'd like to know how you finally find a solution~

    #4579

    Webfreelance
    Participant
    Post count: 29

    Simple solution!
    Install this plugin http://wordpress.org/plugins/wp-youtube-lyte/

    Create a custom field called youtubeid and on the input side only put the video id.
    EG: http://www.youtube.com/watch?v=gRyPjRrjS34 – only the bolded part.

    Then write a function to display the output, add this in your page template.

    <?php
    $tubeid =  get_field('youtubeid'); // The parameter name 
    $newTubeid = $tubeid;// appending the values
    ?>

    Place this in your template where you want the video to show.

    <?php do_shortcode('[lyte id="'.$newTubeid.'" /]'); ?>

    #4581

    Webfreelance
    Participant
    Post count: 29

    Because you are using wp userfrontend pro your function should be this.

    <?php
    $tubeid =  get_post_meta( $post->ID, ‘youtubeid’, true ); // The parameter name 
    $newTubeid = $tubeid;// appending the values
    ?>
    #4582

    Webfreelance
    Participant
    Post count: 29

    If you are going to make this function work for multiple youtube videos then put the function in your loop below <?php while (have_posts()) : the_post(); ?> then the this outside the loop <?php do_shortcode('[lyte id="'.$newTubeid.'" /]'); ?>

    The each time you input a video id for individual posts it will show the id specific video on the post 🙂

    #4584

    LJA32118
    Participant
    Post count: 7

    For some reason – this did not work for me in my single.php – I did put it inside the loop.

    If I include a YouTube link inside the “content” it works fine. I tried creating a textarea (with RichText turned off) and using that for the link, but it did not work – it just displayed the link url.

    #4585

    Tareq Hasan
    Keymaster
    Post count: 2831

    Try this:

    [php]
    <?php echo wp_oembed_get( get_post_meta($post->ID, ‘you_tube_link', true) ); ?>
    [/php]

    #4586

    LJA32118
    Participant
    Post count: 7

    Works perfectly – thanks again!

    #4587

    paperweight
    Participant
    Post count: 122

    Yes, seems to work well with oembed 🙂

    #5617

    onafets
    Participant
    Post count: 30

    sorry, I need to get this thing work,

    this is what I append to my function.php

    function wpuf_youtubeid( $post_id ) {
    $tubeid =  get_post_meta( $post->ID, ‘youtubeid’, true ); // The parameter name 
    $newTubeid = $tubeid;// appending the values
    }

    and this in my single.php
    <?php echo wp_oembed_get( get_post_meta($post->ID, 'you_tube_link', true) ); ?>

    In the form I add a custom TEXT FIELD for the youtube id

    Is it all right?
    It doesn't work for me.

    #5619

    Mahi
    Member
    Post count: 1555

    @onafets

    when you put <?php echo wp_oembed_get( get_post_meta($post->ID, 'you_tube_link', true) ); ?>

    make sure your yourtube custom field meta key is – you_tube_link

    does it makes sense ?

    #5621

    onafets
    Participant
    Post count: 30

    Sorry, I don't think to follow, do you mean this:

    I have this doubt, shall I create a new custom post type or is the plugin wp youtube lyte that makes all of it

    #5636

    Tareq Hasan
    Keymaster
    Post count: 2831

    You don't need to create any function. Just make sure you have a full youtube video URL in that custom field and it should work.

Viewing 15 posts - 1 through 15 (of 15 total)

The topic ‘You Tube Link’ is closed to new replies.