WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Video Thumbnails] fetching video thumbnails upon frontend post creation (4 posts)

  1. Alexander Zeiher
    Member
    Posted 2 years ago #

    I'm using the plugin Video Thumbnails to fetch thumbnails from a video url specified in a custom field.
    It works great in the bakend, but on my site the posts are submitted on the front end with this code:

    <?php
    
    if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] )) {
    
    	if (isset ($_POST['title'])) {
    		$title =  $_POST['title'];
    	} else {
    		echo 'Please enter a title';
    	}
    	if (isset ($_POST['description'])) {
    		$description = $_POST['description'];
    	} else {
    		echo 'Please enter the content';
    	}
    
    	$video_url = $_POST['videourl'];
    
    	$post = array(
    		'post_title'	=> $title,
    		'post_content'	=> $description,
    		'post_status'	=> 'publish',
    		'post_type'     => 'post',
    	);
    	$the_post_id = wp_insert_post($post);
    
    	update_post_meta( $the_post_id, '_videoembed', $video_url);
    
    	wp_redirect( home_url(dashboard) ); 
    
    }
    do_action('wp_insert_post', 'wp_insert_post'); 
    
    ?>

    How do I launch the functionality of the plugin after submitting the new post?
    So that the video thumbnail is fetched from its source and set as post_thumbnail...

  2. Sutherland Boswell
    Member
    Posted 2 years ago #

    Assuming you've already modified the plugin for the custom field, all I think you'll need to do is add a line right after update_post_meta( $the_post_id, '_videoembed', $video_url); with get_video_thumbnail($the_post_id);

  3. Alexander Zeiher
    Member
    Posted 2 years ago #

    It worked thanks :)

  4. vaibhav4
    Member
    Posted 1 year ago #

    Hey @zAPF

    Can u give me the full code of your video-submission code
    i am currently trying hard to find this code
    Thanks in Advance

Topic Closed

This topic has been closed to new replies.

About this Topic