Forum Replies Created

Viewing 1 replies (of 1 total)
  • The bug you described still exists in WordPress 2.3.2 when comments occur after the Recent Posts widget. I have written code which replaces the faulty portion of the Recent Posts widget, providing the same functionality but without interfering with comments.

    You will need to edit wp-includes/widgets.php as follows:

    REMOVE OR COMMENT OUT THE FOLLOWING:

    $r = new WP_Query("showposts=$number&what_to_show=posts&nopaging=0&post_status=publish");
    	if ($r->have_posts()) :
    ?>
    		<?php echo $before_widget; ?>
    			<?php echo $before_title . $title . $after_title; ?>
    			<ul>
    			<?php  while ($r->have_posts()) : $r->the_post(); ?>
    			<li><a href="<?php the_permalink() ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?> </a></li>
    			<?php endwhile; ?>
    			</ul>
    		<?php echo $after_widget; ?>
    <?php
    	endif;

    REPLACE THAT WITH:

    // BEGIN Recent Comments patch added by Morgan
    	global $wpdb;
    	$recent_posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status='publish' ORDER BY post_date DESC LIMIT $number");
    	echo $before_widget;
    	echo $before_title . $title . $after_title;
    	echo "<ul>\n";
    	foreach($recent_posts as $recent_post)
    	{
    		$recent_url = ($recent_post->guid)?$recent_post->guid:"/index.php?p=$recent_post->ID";
    
    		echo "<li><a href='$recent_url'>".$recent_post->post_title."</a></li>\n";
    	}
    
    	echo "</ul>\n";
    	echo $after_widget;
    	// END Recent Comments patch added by Morgan

    ~ Morgan Sherwood
    Philosophy Factory

Viewing 1 replies (of 1 total)