Tutorial: How to Have a Sidebar for the MND Video Vault Pages

This tutorial can be used to add a second sidebar to your WP site, visible only on certain pages/posts. It’s adapted to the MND Video Vault plugin, but it can also be used for other purposes.

MND Video Vault is an easy-to-use plugin that allows you to add a media archive to your WordPress site.

The plugin can be used both on a different WP Installation, or on your main site (you don’t have to update more WP sites, while having all your video entries separated and organized):

You might want to take advantage of the 3 widgets built in the plugin – Latest Videos, Popular Videos, and Video Counter:

You can also use the free WP plugin Custom Post Type Widgets to add widgets like Categories, Search, Tag Cloud, specific to the video posts:

If you use MND Video Vault on your main site and want to use this options, you need a different sidebar on your video pages than on your news/career pages. Here’s how to do that.

I’ll be using the WP theme from my Premade #14 for this tutorial.

Step 1

Default Widgets view in the WP Dashboard:

sidetut01

Go to your WP theme’s folder and open to edit the file functions.php. Find the function that makes it widget-ready:

function mnd_widgets_init() {
register_sidebar( array(
'name' => 'Sidebar Widgets',
'id' => 'sidebar-1',
'description' => 'Add widgets here to appear in your sidebar.',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'mnd_widgets_init' );

Copy & paste the register_sidebar block, then edit it – change the name, the id (remember it for later), and the description. The rest should remain the same:

function mnd_widgets_init() {
register_sidebar( array(
'name' => 'Sidebar Widgets',
'id' => 'sidebar-1',
'description' => 'Add widgets here to appear in your sidebar.',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );

register_sidebar( array(
'name' => 'Sidebar Video Widgets',
'id' => 'sidebar-2',
'description' => 'Add widgets here to appear in your sidebar on video pages.',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'mnd_widgets_init' );

If you go to the Widgets view in the WP Dashboard, you’ll see the new sidebar:

sidetut02

Adding widgets now will have no effect, first we need to make the theme ready for the new sidebar.

Step 2

Go to your default WP theme’s folder and make a copy of sidebar.php, then rename it sidebar-video.php.

Open the new sidebar file to edit and change the sidebar’s id to the one you set up in the step above, in functions.php.

In this case, sidebar-1 becomes sidebar-2:

<?php if ( is_active_sidebar( 'sidebar-2' ) ) :
dynamic_sidebar( 'sidebar-2' );
endif; ?>

Other type of code you might encounter:

<?php if ( ! function_exists( 'dynamic_sidebar' ) || ! dynamic_sidebar( 'sidebar-2' ) ) : ?>
<?php endif; ?>

Step 3

This is where you might have to open almost all the files in your theme: you need to find the following code

<?php get_sidebar(); ?>

and replace it with

<?php
if ( get_post_type() == 'mndvault_video' ) :
get_sidebar( 'video' );
else :
get_sidebar();
endif;
?>

Depending on your theme, the <?php get_sidebar(); ?> line could be in the following files:

1. footer.php or header.php
2. all of the following: 404.php, archive.php, index.php, page.php, search.php, single.php

Step 4

Start adding your widgets:

sidetut03

Final result:

sidetut04

Optional

If you use a video vault page, you might want to show the Video Widgets on this page to.

Go to WP Dashboard -> Pages -> Hover over the Video Archive page. The Edit | Quick Edit… links appear -> Hover over the Edit link to see the page ID:

sidetut05

Go to the theme folder and open to edit the file footer.php – > Find the line

if ( get_post_type() == 'mndvault_video' ) :

replace it with

if ( ( get_post_type() == 'mndvault_video' ) || is_page( 92 ) ) :

Replace 92 with your page ID.

Final result:

sidetut06

One response... add one

Leave a Reply

Your email address will not be published. Required fields are marked *