• Resolved qoster

    (@qoster)


    hello, there is any way to save youtube url to post data ( for example in “post_name” variable ) ? Or maybe there is other way to grab video url?

    I just want to create gallery posts as image + url with forwarding to youtube ( not open on my page ).

    In my code i grab thumbnail and title but cant grab video Url :/

    		if ( $query->have_posts() && $query != NULL) :
    			
    				echo '<div class="row">';
    			while ( $query->have_posts() ) : $query->the_post();
    				$post_ID = get_the_ID();
    				$post_thumbnail = get_the_post_thumbnail_url($post_ID);
    				$post_title = get_the_title( $post );
    				echo '<div class="item-portfolio col-sm-6 col-md-3 col-lg-3">';
    				echo '<div class="bg-hover"><p>'.$post_title.'</p><i class="fa fa-play-circle-o absolute-center fa-vid-play" aria-hidden="true"></i></div>';
    
    				echo '<img class="vid-item item-portfolio" data-id="'.$post_ID.'" src="' . $post_thumbnail . '"></div>';
    				
    			endwhile;
    				echo '</div>';
    
    			/* Restore original Post Data */
    		else :
    			__return_zero();
    		endif;
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author tubegtld

    (@tubegtld)

    Here’s revised code that grabs the video URL and uses it to link over…

    if ( $query->have_posts() && $query != NULL) :
    			
      echo '<div class="row">';
    
        while ( $query->have_posts() ) : $query->the_post();
          
          $post_ID = get_the_ID();
          
          $post_thumbnail = get_the_post_thumbnail_url($post_ID);
          
          $post_title = get_the_title( $post );
    
          // get the video URL for the post
          $video_url = get_post_meta( $post_ID, 'tube_video_oembed_url', true);
    
          echo '<div class="item-portfolio col-sm-6 col-md-3 col-lg-3">';
          
          echo '<div class="bg-hover"><p><a href="'.esc_url($video_url).'">'.$post_title.'</a></p><i class="fa fa-play-circle-o absolute-center fa-vid-play" aria-hidden="true"></i></div>';
          
          echo '<img class="vid-item item-portfolio" data-id="'.$post_ID.'" src="' . $post_thumbnail . '"></div>';
          
        endwhile;
          
      echo '</div>';
    
    /* Restore original Post Data */
    else :
    
      __return_zero();
    
    endif;
    Thread Starter qoster

    (@qoster)

    Thank You very much, that works form me ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Save YT vid url to post object.’ is closed to new replies.