Support » Plugins » Hacks » Help me get the excerpt!

  • kevorgod

    (@kevorgod)


    Hi there.. I try to modify a widget to show what i want… But i can’t get the excerpt to show! Can you help me with this ?

    function widget( $args, $instance ) {
    		extract( $args );
    
    		/* Our variables from the widget settings. */
    		$title = apply_filters('Recent Posts', $instance['title'] );
    		$post_cat = $instance['post_cat'];
    		if($post_cat == "All"){ $post_cat = ''; }
    		$show_num = $instance['show_num'];
    
    		/* Before widget (defined by themes). */
    		echo $before_widget;
    		if($title)
    			echo $before_title . $title . $after_title;
    
    		/* Display the widget title if one was input (before and after defined by themes). */
    		$custom_posts = get_posts('showposts='.$show_num.'&cat='.get_cat_ID($post_cat));
    		if( !empty($custom_posts) ){
    			echo "<div class='gdl-recent-conference-widget'>";
    			foreach($custom_posts as $custom_post) {
    				?>
    				<div class="recent-conference-widget">
    					<div class="recent-conference-widget-thumbnail">
    						<a href="<?php echo get_permalink( $custom_post->ID ); ?>">
    							<?php
    								$thumbnail_id = get_post_thumbnail_id( $custom_post->ID );
    								$thumbnail = wp_get_attachment_image_src( $thumbnail_id , '280x111' );
    								$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
    								if( !empty($thumbnail) ){
    									echo '<img src="' . $thumbnail[0] . '" alt="'. $alt_text .'"/>';
    								}
    							?>
    						</a>
    					</div>
    					<div class="recent-conference-widget-context">
    
    						<p>
    							<?php echo get_the_excerpt( $custom_post->ID ); ?>
    						</p>
    
    						<a href="<?php echo get_permalink( $custom_post->ID ); ?>">
    							Read More
    						</a>
    					</div>
    					<div class="clear"></div>
    				</div>
    				<?php 
    
    			}
    			echo "</div>";
    		}
    		/* After widget (defined by themes). */
    		echo $after_widget;
    	}

    Thx in advance

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help me get the excerpt!’ is closed to new replies.