Support » Fixing WordPress » Popular/Latest Widget problem with Simple Facebook Connect

  • Resolved ruls

    (@ruls)


    Well, so I installed Simple Facebook Connect and everything runned smooth until I commented on a post login with facebook connect and when the “share on facebook” window came up the article that was “sharing” was not the one I was commenting on but other one.

    After a lot of research in the plugin creator’s website, I found that the problem was caused by the Popular/Latest Widget that comes with my theme, so that the last article that shows up in the latest post list is the one that is appearing in the “sharing” window. Apparently this is bad coding of The Loop and Query stuff.

    So the author of the plugin said to come here to the wordpress forums to ask for help… please, forum gods of code, help this not so good for coding user get his blog on track.

    The code in the Latest Post Widget is:

    <ul>
    				<?php
    					$the_query = new WP_Query('cat=' . $ex_feat . '&showposts=10&orderby=post_date&order=desc');
    					while ($the_query->have_posts()) : $the_query->the_post(); $do_not_duplicate = $post->ID;
    				?>
    				<li>
    					<?php woo_get_image('image',35,35,'thumbnail',90,$post->ID,'src',1,0,'','',true,false,false); ?>
    					<a title="<?php _e('Permalink to ',woothemes); ?> <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
    					<div class="fix"></div>
    				</li>
    				<?php endwhile; ?>
    			</ul>

    The code of the Popular Widget, which is before the LatestPost one and becomes the one making the problem if I take down the other one:

    <?php
    $pop_posts = get_option('woo_popular_posts');
    if (empty($pop_posts) || $pop_posts < 1) $pop_posts = 5;
    $now = gmdate("Y-m-d H:i:s",time());
    $lastmonth = gmdate("Y-m-d H:i:s",gmmktime(date("H"), date("i"), date("s"), date("m")-24,date("d"),date("Y")));
    $popularposts = "SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS 'stammy' FROM $wpdb->posts, $wpdb->comments WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish' AND post_date < '$now' AND post_date > '$lastmonth' AND comment_status = 'open' GROUP BY $wpdb->comments.comment_post_ID ORDER BY stammy DESC LIMIT ".$pop_posts;
    $posts = $wpdb->get_results($popularposts);
    $popular = '';
    if($posts){
    	foreach($posts as $post){
    		$post_title = stripslashes($post->post_title);
    		$guid = get_permalink($post->ID);
    ?>
    		<li>
    			<?php
    				woo_get_image('image',35,35,'thumbnail',90,$post->ID,'src',1,0,'','',true,false,false);
    			?>
                <a href="<?php echo $guid; ?>" title="<?php echo $post_title; ?>"><?php echo $post_title; ?></a>
        		<div style="clear:both"></div>
    
            </li>
    <?php
    	}
    }
    ?>

    All help will be very much appreciated

Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Popular/Latest Widget problem with Simple Facebook Connect’ is closed to new replies.