How can I add my own videos to the Video tutorial section?

Hi there!
I want to add my own video tutorials to the video tutorial section created with the WPMU DEV Videos.
How do I do that?
Thanks
Guy

  • Sajid

    Hi Guy,
    Hope you are doing good today :slight_smile:

    There is no way to add custom videos from backend. However, you can do this by using the following filter hooks.

    Add it in functions.php file of your active child theme or use it as mu-plugin.

    If you take the mu-plugin route, you'll want to log into your site via FTP, and go to your /wp-content/ folder via FTP, finding the folder called "mu-plugins".

    If there's no folder with that name, then you'll want to create one. Then, create a file inside that folder, and give the file any name you like (making sure the file has an extension of .php, e.g. example.php) and paste the code in there.

    It'll always be active, so there's no need to activate the plugin after creation. Be sure to add a PHP start tag at the beginning of the code, like this:

    <?php

    After adding, you have to change the URL of the video and label (My Favorite Vid) in the example.

    add_filter('wpmudev_vids_list', function( $video_list ) {
    	$video_list[ 'myvid' ] = 'My Favorite Vid';
    	return $video_list;
    });
    
    add_filter('wpmudev_vids_categories', function( $video_cats ) {
    	//add to other category
    	$video_cats[ 'other' ][ 'list' ][] = 'myvid';
    
    	//create my own category
    	$video_cats['mine'] = array(
    		'name' => 'My Category',
    		'list' => array( 'myvid' )
    	);
    
    	return $video_cats;
    });
    
    add_filter('wpmudev_vids_embed_html', function( $video_html, $slug ) {
    	if ( 'myvid' == $slug ) {
    		$video_html = '<iframe width="640" height="480" src="https://www.youtube.com/embed/dQw4w9WgXcQ?rel=0&controls=0&showinfo=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';
    	}
    
    	return $video_html;
    }, 10, 2);

    Take care and have a nice day :slight_smile:

    Best Regards,
    Sajid

  • Sajid

    Hi Guy,
    Hope you are doing good today :slight_smile:

    To add more videos just modify the existing code of each function. For example, to add video into list add following:
    $video_list[ 'myvid2' ] = 'My Favorite Vid 2';

    under the existing:
    $video_list[ 'myvid' ] = 'My Favorite Vid';

    To add video in same category just the ID of video we registered above separated by coma like below.

    $video_cats['mine'] = array(
    	'name' => 'My Category',
    	'list' => array( 'myvid', 'myvid2' )
    );

    Finally we have to give the exact video code too in third function by adding following code:

    if ( 'myvid2' == $slug ) {
    		$video_html = '<iframe width="640" height="480" src="https://www.youtube.com/embed/yPYZpwSpKmA?rel=0&controls=0&showinfo=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';
    	}

    under this:

    if ( 'myvid' == $slug ) {
    		$video_html = '<iframe width="640" height="480" src="https://www.youtube.com/embed/dQw4w9WgXcQ?rel=0&controls=0&showinfo=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';
    	}

    Repeat it and change the ID and label to add more videos.

    The final code with above changes will look like this:

    add_filter('wpmudev_vids_list', function( $video_list ) {
    	$video_list[ 'myvid' ] = 'My Favorite Vid';
    	$video_list[ 'myvid2' ] = 'My Favorite Vid 2'; 
    
    	return $video_list;
    });
    
    add_filter('wpmudev_vids_categories', function( $video_cats ) {
    	//add to other category
    	$video_cats[ 'other' ][ 'list' ][] = 'myvid';
    
    	//create my own category
    	$video_cats['mine'] = array(
    		'name' => 'My Category',
    		'list' => array( 'myvid', 'myvid2' )
    	);
    
    	return $video_cats;
    });
    
    add_filter('wpmudev_vids_embed_html', function( $video_html, $slug ) {
    	if ( 'myvid' == $slug ) {
    		$video_html = '<iframe width="640" height="480" src="https://www.youtube.com/embed/dQw4w9WgXcQ?rel=0&controls=0&showinfo=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';
    	}
    
    	if ( 'myvid2' == $slug ) {
    		$video_html = '<iframe width="640" height="480" src="https://www.youtube.com/embed/yPYZpwSpKmA?rel=0&controls=0&showinfo=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';
    	}
    
    	return $video_html;
    }, 10, 2);

    Hope that helps! Feel free to post a reply if you need further assistance :slight_smile:

    Best Regards,
    Sajid

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.