Classifier Modification: Add Video

Hi again!

This time, i will share a modification for your Classifier theme. This modification will give you a new feature to displaying a video that replacing the slider section.


As you can see, the video section will replacing the slider. This option will be made to be optional, which means you can turn on the slider again if you want.

The concept of this modification is, you have to create a new post, add a category into it and don’t forget to add an embed code to it. Video size doesn’t matter since this modification will automatically re-sizing your video size.

Step #1

At this first step you have to modify a file named theme-options.php. You can find out this code by logging in into your FTP and go to directory: wp-content > themes > classifier > includes.

Open that file and find out this code:

// FrontPage Options
$options[] = array( "name" => __("FrontPage Settings", "colabsthemes" ),
					"type" => "heading",
					"icon" => "home");

Once you find it, you can put this code just after it:

$options[] = array( "name" => "Switch slider to video?",
					"desc" => "Activate this option to displaying a video instead of slider",
					"id" => $shortname."_video_active",
					"class" => "collapsed",
					"type" => "checkbox");
$options[] = array( "name" => "Video Category",
					"desc" => "Select category for Video section. ",
					"id" => $shortname."_video",
					"type" => "select2",
					"class" => "hidden last",
					"options" => $colabs_categories );  

If you already done with it, you already done with the first step. You can check it by going to WordPress dashboard > Classifier > dashboard > front page settings.

You will have a new option named switch slider to video, activate this option if you want to turn off the slider and activate the video. After activating, a new option will be displayed: video category. At this option you have to choose which post should be displayed at the video category based on its category.

Step #2

At this step, we have to call the result of our new options, the logic and category. You have to modify a file named header.php (FTP > wp-content > themes > classifier).

Open the file and find out this code:

<?php get_template_part('includes/featured','main'); ?>
		$arr = array(
			'theme_location' => 'secondary-menu',
			'container' => 'div',
			'container_class' => 'category-listing',
			'fallback_cb' => 'secondarymenu',
		wp_nav_menu($arr); ?>

Once you did it, modify those codes become:

&lt;?php if(get_option( &quot;colabs_video_active&quot;) != &quot;true&quot;) { ?&gt;
		&lt;?php get_template_part('includes/featured','main'); ?&gt;
		$arr = array(
			'theme_location' =&gt; 'secondary-menu',
			'container' =&gt; 'div',
			'container_class' =&gt; 'category-listing',
			'fallback_cb' =&gt; 'secondarymenu',
		wp_nav_menu($arr); ?&gt;
	&lt;?php } else { ?&gt;	
		&lt;style type=&quot;text/css&quot;&gt;
			.cover {padding: 10px;}
		&lt;div class=&quot;cover&quot;&gt;
						$ar_video = get_option( &quot;colabs_video&quot; );
						if( $ar_video == 0 ) { $ar_video = $cp_categories[0]-&gt;cat_ID; } 
						$video_query = new WP_Query( 'showposts=1&amp;cat=' . $ar_video ); 
						&lt;?php while ($video_query-&gt;have_posts()) : $video_query-&gt;the_post(); ?&gt;
								$video = colabs_embed('width=950&amp;height=450');
								if ($video!=&quot;&quot;) { echo $video; } else {
									$pattern = '!&lt;param name=&quot;movie&quot;.*?value=&quot;(.*?)&quot;!';
									preg_match_all($pattern, $the_content, $matches);
									if( isset( $matches['1'][0] ) ) {
										$video_src = $matches['1'][0]; 
									} else {
										$video_src = '';
									if ($video_src !=&quot;&quot;) { ?&gt;       
										<a href="?phpecho$video_src;?">?phpecho$video_src;?</a>
								&lt;?php } ?&gt;
							&lt;?php } ?&gt;
						&lt;?php endwhile; ?&gt;
			&lt;?php } ?&gt;	

And done! Right now you will be able to switch the slider into video.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s