Return to Snippet

Revision: 57520
at September 29, 2012 02:51 by crypticsoft


Updated Code
//add to functions.php 
add_post_type_support('slide', 'excerpt');

//template loop for content slides
$loop = new WP_Query( array(
		'post_type'      => 'slide',
		//'slideshow'      => $slideshow,
		'posts_per_page' => $options['slideshow_quantity'],
		'orderby'		=> 'ID',
		'order'			=> 'ASC'
	) ); 

	 // Loop which loads the slideshow
		while ( $loop->have_posts() ) : $loop->the_post();

		$attr = array(
			'class'	=> "imageItem alignleft",
			'title'	=> get_the_title( $post->ID )			
		);	
				// Adds slide image with Slide URL link
				$slide_img = '<a href="' . get_post_meta( $post->ID, "slide_url_value", $single = true ) .'">' . get_the_post_thumbnail( $post->ID, array(285,200), 'featured-slide' ) . '</a>';
				$slide_desc = get_the_excerpt( $post->ID );

				$result .= '<li class="royalSlide"> 
				        	<div class="centeredSlide" style="margin-top:28px;">
				                <div class="slideTextBlock">
				                    <h4 class="coda">' . get_the_title( $post->ID ) . '</h4>
				                    <p>' . $slide_desc . '</p>
				                </div>' . $slide_img . '
				            </div>';
		endwhile;

Revision: 57519
at May 30, 2012 08:10 by crypticsoft


Initial Code
/* 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 &raquo;</a></div>';

				 // Adds slide image without Slide URL link
					
				else: 
					
					the_post_thumbnail( 'featured-slide' );
					
				endif;

Initial URL


Initial Description
For when you really just need a short description field along with a title for your slideshows. Just drop this into the functions.php and meteor-slideshow.php in the theme folder.

Initial Title
Meteor Slides : WordPress Plugin : Adding Excerpt for Slides

Initial Tags
plugin, wordpress

Initial Language
PHP