WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Popular/Latest Widget problem with Simple Facebook Connect (8 posts)

  1. ruls
    Member
    Posted 4 years ago #

    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

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 4 years ago #

    Try adding this after the extra loop you're using:

    <?php wp_reset_query(); ?>

    That resets the query back to its proper operation.

  3. ruls
    Member
    Posted 4 years ago #

    you are awesome, it worked perfectly... thanks!!

  4. ruls
    Member
    Posted 4 years ago #

    Otto, sorry to bother you again but now I tried to instal the Simple Twitter Connect and when you click on the button to log in with twitter or to comment with twitter, it takes you to a blank page and that's it.

    I went to check the one in your site and saw that it works perfectly (taking you to twitter and back).

    Do you know what could be the problem with the one in my site?

    Thanks for all your help

  5. ruls
    Member
    Posted 4 years ago #

  6. Samuel Wood (Otto)
    Tech Ninja
    Posted 4 years ago #

    Well, obviously something is failing in your PHP, but without errors being turned on, I have no way to tell. Try turning on debug mode on your site. Just add define('WP_DEBUG', true); to your wp-config.php file, see if this makes it spit out an error message instead of nothingness.

  7. ruls
    Member
    Posted 4 years ago #

    Added the debug line to wp-config.php but nothing different happened.

    Any other ideas?

  8. Samuel Wood (Otto)
    Tech Ninja
    Posted 4 years ago #

    Nope. Sorry. Without getting some kind of error, I have no way to debug what the problem with your site is.

    Try disabling other plugins, perhaps one is interfering or something.

    The problem isn't with the plugin, BTW. That particular piece of code is the simplest possible code. It just redirects to Twitter. Nothing special about it.

Topic Closed

This topic has been closed to new replies.

About this Topic