Editing widget.php in WordPress for News List widget

I’m trying to edit the text that shows up for my ‘News List’ widget for my wordpress site. Right now it is only pulling the first few words of the blog post, and instead would like it to show the title of the posts. Please bear with me - totally new at php, so I’m nervous of messing it up and causing a bigger problem for myself!

Contact me if you need more info - thanks in advance for your help!

Here is the current code in the widgets.php file

[php]// Widget News List
class Widget_News_List extends WP_Widget{
function Widget_News_List(){
$widget_ops = array(‘description’ => __( “News List widget.” ), ‘classname’ => ‘news-box’ );
$this->WP_Widget(‘news-box’, __(‘News List’), $widget_ops);
}
function widget($args, $instance){
extract( $args );
$title = apply_filters(‘widget_title’, empty($instance[‘title’]) ? __(’’) : $instance[‘title’]);
$numb = (int) $instance[‘number’];
$cat = (int) $instance[‘cat’];
$str_len = (int) $instance[‘len’];
global $post;

	if(!$numb) $numb = 5;
	if(!str_len) $str_len = 75;
	
	$q = "showposts=$numb&orderby=date&order=DESC";
	if($cat) $q .= "&cat=$cat";
	query_posts($q);
	?>
	<?php if (have_posts()) : ?>
		<?php echo $before_widget; ?>
			<?php if($title && $title != '') echo $before_title . $title . $after_title; ?>
			<ul>
				<?php while (have_posts()) : the_post(); ?>
				<li>
					<div class="date">
						<strong><?php the_time('d'); ?></strong>
						<span><?php the_time('M'); ?></span>
					</div>
					<div class="news-text">
						<p><a href="<?php the_permalink(); ?>"><?php echo substr(strip_tags($post->post_content), 0, 42).'...' ?></a></p>
						<a href="<?php the_permalink(); ?>">Read More »</a>
					</div>
				</li>
				<?php endwhile; ?>
			</ul>
			<?php
				$posts_page = get_settings('page_for_posts'); 
				if(empty( $posts_page)) $posts_page = get_bloginfo('home'); 
				else $posts_page = get_permalink($posts_page);
			?>
			<div class="link"><a href="<?php echo $posts_page; ?>"> More News »</a></div>
		<?php echo $after_widget; ?>
		<?php endif; ?>
		<?php wp_reset_query(); ?>
	<?
}
function update($new_instance, $old_instance){
	return $new_instance;
}
function form($instance){
	$title = esc_attr($instance['title']);
	$numb = esc_attr($instance['number']);
	$len = esc_attr($instance['len']);
	$cat = esc_attr($instance['cat']);
	?>
		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('cat'); ?>"><?php _e('Category:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('cat'); ?>" name="<?php echo $this->get_field_name('cat'); ?>" type="text" value="<?php echo $cat; ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $numb; ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('len'); ?>"><?php _e('number of characters:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('len'); ?>" name="<?php echo $this->get_field_name('len'); ?>" type="text" value="<?php echo $len; ?>" /></label></p>
	<?php[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service