//Open up header.php in the theme editor. Add these three lines of code somewhere between the <head> and </head>
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/slider.css" type="text/css" media="screen" charset="utf-8">
<script src="<?php bloginfo('template_directory'); ?>/js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="<?php bloginfo('template_directory'); ?>/js/slider.js" type="text/javascript" charset="utf-8"></script>
//Now that we have loaded the css and javascripts required for running the slider, we can now include the slider.php Wordpress template file in your theme files. Open up index.php or home.php and locate spot where you want to include the slider. If you are using our Modularity theme framework, you might insert the slider right above this line of code:
<?php
$featured = get_option('T_featured');
if($featured == "On") { include (THEMELIB . '/apps/featured.php'); }
?>
//Paste this right above it:
<?php include ('slider.php') ?>
//Finally, we are going to create a custom write panel to your Wordpress post, so that you can choose a thumbnail for each post. Open up your functions.php file and add this code right above the very last ?>.
// Custom Write Panel
$meta_boxes =
array(
"image" => array(
"name" => "image",
"type" => "text",
"std" => "",
"title" => "Image",
"description" => "Using the \"<em>Add an Image</em>\" button, upload an image and paste the URL here. Images will be resized. This is the post main image and will automatically be sized.")
);
function meta_boxes() {
global $post, $meta_boxes;
echo'
<table class="widefat" cellspacing="0" id="inactive-plugins-table">
<tbody class="plugins">';
foreach($meta_boxes as $meta_box) {
$meta_box_value = get_post_meta($post->ID, $pre.'_value', true);
if($meta_box_value == "")
$meta_box_value = $meta_box['std'];
echo'<tr>
<td width="70" align="center">';
echo'<input type="hidden" name="'.$meta_box['name'].'_noncename" id="'.$meta_box['name'].'_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />';
echo'<h2>'.$meta_box['title'].'</h2>';
echo' </td>
<td>';
echo'<input type="text" name="'.$meta_box['name'].'_value" value="'.get_post_meta($post->ID, $meta_box['name'].'_value', true).'" size="70%" /><br />';
echo'<p><label for="'.$meta_box['name'].'_value">'.$meta_box['description'].' </label></p>';
echo' </td>
</tr>';
}
echo'
</tbody>
</table>';
}
function create_meta_box() {
global $theme_name;
if ( function_exists('add_meta_box') ) {
add_meta_box( 'new-meta-boxes', 'Photo for post', 'meta_boxes', 'post', 'normal', 'high' );
}
}
function save_postdata( $post_id ) {
global $post, $meta_boxes;
foreach($meta_boxes as $meta_box) {
// Verify
if ( !wp_verify_nonce( $_POST[$meta_box['name'].'_noncename'], plugin_basename(__FILE__) )) {
return $post_id;
}
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ))
return $post_id;
} else {
if ( !current_user_can( 'edit_post', $post_id ))
return $post_id;
}
$data = $_POST[$meta_box['name'].'_value'];
if(get_post_meta($post_id, $meta_box['name'].'_value') == "")
add_post_meta($post_id, $meta_box['name'].'_value', $data, true);
elseif($data != get_post_meta($post_id, $pre.'_value', true))
update_post_meta($post_id, $meta_box['name'].'_value', $data);
elseif($data == "")
delete_post_meta($post_id, $meta_box['name'].'_value', get_post_meta($post_id, $meta_box['name'].'_value', true));
}
}
add_action('admin_menu', 'create_meta_box');
add_action('save_post', 'save_postdata');