• I’ve been using the Blue October theme, which pulls the sidebar before the comments are displayed.

    This has shown a bug, (I presume its a bug, as its very bad behaviour) in the Recent Posts widget.

    If the Recent Posts widget is called after the main body of the post, but before the comments() call, the post ID is completely overwritten by the widget, leaving the comments() function displaying the comments for the *last* post listed in the Recent Comments Widget.

    Surely the Widgets should not interfere with the main content of a page in any way?

    Can anyone confirm or deny that this should actually be classified as a bug, and suggest where it is best reported? I emailed Automattic about it, but received no response.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I can’t be any help, except to say that I’ve found the same problem myself.

    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 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[bug] Recent Posts Widget & Comments’ is closed to new replies.