Support » How-To and Troubleshooting » Edited Loop issue

Edited Loop issue

  • Hi gang —

    I’m no professional developer, though I’m being asked to be one with an issue that I’m experiencing right now with a variant of the loop and a PHP issue.

    Backstory: http://www.tampablab.com has been running as a local blog aggragator site since 2006 and is very popular. My partner just purchased the site from it’s developer and left me in charge of getting it ready to be re-launched. After getting some fo the plug-ins that make the site work sorted out, I had to import a variation of the Loop that was employed on this site:

    <?php while (have_posts()) : the_post(); ?>
    			$TB_time_array[] = date('H:i:s');
    			$post = $wp_query->post;
    			$show_post = true;
    			$guid = get_post_meta($post->ID,'syndication_permalink',TRUE);
    			if (array_key_exists($post->post_author, $listed_posts)) {
    				$post_ids = explode("|", $listed_posts[$post->post_author]);
    				for($i=0; $i < count($post_ids); $i++) {
    					//echo "<!--array:".$post_ids[$i]." | post:".$guid."-->";
    					if ($post_ids[$i] == $guid && $post_ids[$i] != "") {
    						$show_post = false;
    			if ($show_post) {
    				if (the_title('','',false)=="") {
    					$this_title = "[No Title]";
    				} else {
    					$this_title = the_title('','',false);
    				<?php the_date('l, F j, Y', '<div class="datewrap"><h2 class="date">', '</h2></div>'); ?>
    				<div class="post" id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>"><?php echo $this_title; ?></a></h2>
    				<small>Posted by <?php the_author(); ?> at <a href="/go.php?<?php the_permalink(); ?>"><?php echo get_feed_meta('feed/title'); ?></a> - <?php echo date('g:i a', get_the_time('U') + 10800) ?></small>
    				<div class="entry">
    					<?php the_excerpt(); ?>
    				<p class="postmetadata">Categories: <?php the_category(', ') ?> <strong>|</strong> <?php echo wp_ozh_click_getclicks(get_permalink(),'','',''); ?><?php edit_post_link('Edit',' <strong>|</strong> ',''); ?></p>
    				$other_posts = $wpdb->get_results("
    				SELECT ID, post_title, post_date, post_author
    				FROM wp_posts
    				WHERE post_author = $post->post_author
    				AND post_date <= '".get_the_time('Y-m-d H:i:s')."'
    				AND post_date >= DATE_SUB( '".get_the_time('Y-m-d H:i:s')."', INTERVAL 12 HOUR )
    				AND ID != ".$post->ID."
    				ORDER BY post_date DESC
    				if ($other_posts) {
    					//we have other recent posts, print each one in a separate block along with pertinent info
    				<div class="otherposts"><h4>Other recent posts from <?php the_author(); ?>:</h4><ul>
    					foreach ($other_posts as $other_post) {
    						$other_guid = get_post_meta($other_post->ID,'syndication_permalink',TRUE);
    						<li><a href="/go.php?<?=$other_guid?>"><?=$other_post->post_title?></a> | <?php echo wp_ozh_click_getclicks($other_guid,'','',''); ?> | <?=date('h:i A', strtotime($other_post->post_date) + 10800)?><?php
    							if (date('Y-m-d',strtotime($other_post->post_date)) != get_the_time('Y-m-d')) {
    								echo " on ".date('m/d/Y',strtotime($other_post->post_date));
    						//echo "<!--post_author:".$other_post->post_author." | guid:".$other_guid."-->";
    						$listed_posts[$other_post->post_author] .= $other_guid."|";
    		<?php endwhile; ?>

    (dont know if that code will show up properly)

    So I’ve saved thsi as the loop on the test blog that I am using while this is in beta and I’m getting a general PHP warning:

    Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/.piglet/tommyduncn/blab.sticksoffire.com/wp-content/themes/default/index.php on line 11

    This is basically at the top of the loop variant. I should also note that this site has been running in ancient WordPress 1.5.x and this new loop has been installed on WordPress 2.3.2/3

    I’m not quite sure about the conflict but I’d like to figure out how to preserve the loop while fixing the array issue.

  • The topic ‘Edited Loop issue’ is closed to new replies.