I have been a designer by trade for years however I am working with WordPress for a client and have been managing to get by with working with hooks... I am, however now at a standstill.
On the homepage I have two areas which will be pulling information from the database:
<?php
$thumb_posts = get_posts(array('category' => '6', 'orderby' => 'rand', 'numberposts' => 2, 'meta_key' => '_thumbnail_id' ));
if($thumb_posts) { ?>
<?php foreach( $thumb_posts as $post ) {
echo '<div class="feature"><div class="thumbnail">
<a href="' . get_permalink($header_thumb->ID) . '">' . get_the_post_thumbnail($header_thumb->ID,array(240,170)) . '</a></div>';
$url = get_permalink($post->ID);
$filecontent = file_get_contents('https://graph.facebook.com/?ids=' . $url);
$json = json_decode($filecontent);
$count = $json->$url->comments;
if ($count == 0 || !isset($count)) {
$count = '0';
} elseif ( $count == 1 ) {
$count = '1';
} else {
$count .= '';
}
echo '<h3 class="title"> <a href="' . get_permalink($header_thumb->ID) . '#comments" class="comments">' . $count . '</a> <a href="' . get_permalink($header_thumb->ID) . '"> ' . get_the_title($ID) . ' </a> </h3></div>';
} ?>
Which I did not write, but calls the facebook comment count of the random post with title and thumbnail.
Here is my problem... Once I place my second code AFTER this it throws off the count/image retrieval. However, if I place this code BEFORE everything works great.
<?php
$thumb_posts = get_posts(array('category' => '6', 'orderby' => 'rand', 'numberposts' => 2, 'meta_key' => '_thumbnail_id' ));
if($thumb_posts) {
?>
<?php
global $post;
$myposts = get_posts('numberposts=20');
foreach($myposts as $post) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> |
<span class="post-info"> <?php echo human_time_diff( get_the_time('U'),
current_time('timestamp') ) . ' ago'; ?> </span></li>
<?php endforeach; ?>
In my thought process, I need to somehow make it so the second code doesn't somehow throw off the first independent code.