Hi everyone I am a sort of medium weight wp designer/developer and having trouble with a site I am working on. The demo page is here:
http://flock.simonpointer.com/blog/
I have inherited the following loop code in the template file, and cannot for the life of me figure out why I seem to be getting 2 outputs for the author info in the featured content box. I seem to get what appears to be a first and second post. On the second one the author photo and link details are not loading but they are on the first one and the post thumbnail is being displayed for the second one but not the first. Any help appreciated:
<div class="col-2-5"><div class="feature-card blog-featured-card">
<?php
//$args = array( 'posts_per_page' => 1);
$loop = new WP_Query(
array(
'post_type' => 'post',
'posts_per_page' => 1
) );
while ( $loop->have_posts() ) : $loop->the_post();
if(isset($post->author)){
$team_id = $post->author;//get the post id of the team indiviual detail page
$author_name = get_the_title( $team_id ); //get the page title from the id
$author_image = wp_get_attachment_url(get_post_meta($team_id, 'image', true));
$image = get_field('image', $team_id);
$author_link = get_permalink($team_id);
$page_elements = array(
'author_name' => $author_name,
'author_image' => $image['sizes']['thumbnail'],
'author_link' => $author_link,
);
$author_html = '<div class="blog-author">
<a href="'.$page_elements['author_link'].'" title="">
<img src="'.$page_elements['author_image'].'" alt="'.$page_elements['author_name'].'" />
</a>
<span>By <a href="'.$page_elements['author_link'].'">'.$page_elements['author_name'].'</a></span>
</div>';
}
echo '<div class="blog-feature-go">';
echo '<p><a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_post_thumbnail().'</a></p>';
echo '<h2 class="test-headin"><a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_title().'</a></h2>';
echo $author_html;
echo '<div><a class="text-arrow-cta cta-button read-more-button" href="'.get_permalink().'" title="'.get_the_title().'">Read More</a></div>';
echo '</div>';
endwhile;
?>