/* add these functions to functions.php in wordpress theme folder */
// Adds meta box for Slide Description - meteorslides addon
add_action( 'admin_menu', 'meteorslides_create_desc_meta_box' );
$meteorslides_new_desc_meta_box =
array(
'slide_description' => array(
'name' => 'slide_description',
'std' => ''
)
);
function meteorslides_create_desc_meta_box() {
global $theme_name;
if ( function_exists('add_meta_box') ) {
add_meta_box( 'meteorslides-desc-box', __('Slide Description','meteor-slides'), 'meteorslides_new_desc_meta_box', 'slide', 'normal', 'low' );
}
}
function meteorslides_new_desc_meta_box() {
global $post, $meteorslides_new_desc_meta_box;
foreach ( $meteorslides_new_desc_meta_box as $meteorslides_meta_box ) {
$meteorslides_meta_box_value = get_post_meta( $post->ID, $meteorslides_meta_box['name'].'_value', true );
if( $meteorslides_meta_box_value == "" ) $meteorslides_meta_box_value = $meteorslides_meta_box['std'];
echo "<input type='hidden' name='" . $meteorslides_meta_box['name'] . "_noncename' id='" . $meteorslides_meta_box['name'] . " _noncename' value='" . wp_create_nonce( plugin_basename(__FILE__) ) . "' />";
echo "<input type='text' name='" . $meteorslides_meta_box['name'] . "_value' value='" . $meteorslides_meta_box_value . "' size='55' /><br />";
echo "<p>" . __('Add a short description for this slide.','meteor-slides') . "</p>";
}
}
/* #### Step 2:
//copy the meteor-slideshow.php to your theme folder then simply add the following to show the description field:
*/
// Adds slide image with Slide URL link
if ( get_post_meta( $post->ID, "slide_url_value", $single = true ) != "" ):
print '<a href="' . get_post_meta( $post->ID, "slide_url_value", $single = true ) .'">' . get_the_post_thumbnail( $post->ID, 'featured-slide' ) . '</a>';
print '<div class="hero_about"><h2>'.get_the_title( $post->ID ).'</h2>';
print get_post_meta( $post->ID, "slide_description_value", $single = true );
print '<a href="'.get_post_meta( $post->ID, "slide_url_value", $single = true ).'">Learn More »</a></div>';
// Adds slide image without Slide URL link
else:
the_post_thumbnail( 'featured-slide' );
endif;
Source : http://snipplr.com/view/65267/meteor-slides–wordpress-plugin–adding-description-field/
Leave a Reply