• I have some custom php in a page template to display all the authors on the site along with links and their latest post. On localhost it worked perfectly, however when I upload it, it isn’t displaying as intended. It shows all 3 authors just fine, but above them it shows an author and description from one author, and the links and post from another.

    You can view the problem here: https://www.thevintagegamers.com/about/

    My code:

    <?php
    		$authors = $wpdb->get_results('SELECT DISTINCT post_author FROM '.$wpdb->posts);
    		if($authors):
    		foreach($authors as $author):
    		?>
    		<div class='author' id='author-<?php the_author_meta('user_login', $author->post_author); ?>'>
    			<h3><?php the_author_meta('display_name', $author->post_author); ?></h3>
    
    			<?php if(get_the_author_meta('description', $author->post_author)): ?>
    			<div class='description'>
    				<?php echo get_avatar(get_the_author_meta('user_email', $author->post_author), 80); ?>
    				<p><?php the_author_meta('first_name', $author->post_author); ?> <?php the_author_meta('description', $author->post_author); ?></p>
    			</div>
    			<?php endif; ?>
    
    			<?php
    			$recentPost = new WP_Query('author='.$author->post_author.'&showposts=1');
    			while($recentPost->have_posts()): $recentPost->the_post();
    			?>
    			<h4>Recent Post: <a href='<?php echo get_permalink();?>'><?php the_title(); ?></a></h4>
    			<?php endwhile; ?>
    			<?php if(get_the_author_meta('twitter', $author->post_author) || get_the_author_meta('facebook', $author->post_author) || get_the_author_meta('aim', $author->post_author) || get_the_author_meta('url', $author->post_author) || get_the_author_meta('sitename', $author->post_author)): ?>
    			<ul class='connect'>
    				<?php if(get_the_author_meta('url', $author->post_author)): ?>
    				<li><a href='<?php the_author_meta('url', $author->post_author); ?>' class="website"><?php the_author_meta('sitename', $author->post_author); ?></a></li>
    				<?php endif; ?>
    				<?php if(get_the_author_meta('aim', $author->post_author)): ?>
    				<li><a href='aim:goim?screenname=<?php the_author_meta('aim', $author->post_author); ?>' class="aim"><?php the_author_meta('aim', $author->post_author); ?></a></li>
    				<?php endif; ?>
    				<?php if(get_the_author_meta('twitter', $author->post_author)): ?>
    				<li><a href='https://twitter.com/<?php the_author_meta('twitter', $author->post_author); ?>' class="twitter">Twitter</a></li>
    				<?php endif; ?>
    				<?php if(get_the_author_meta('facebook', $author->post_author)): ?>
    				<li><a href='https://www.facebook.com/<?php the_author_meta('facebook', $author->post_author); ?>' class="facebook">Facebook</a></li>
    				<?php endif; ?>
    
    			</ul>
    			<?php endif; ?>
    		</div>
    		<?php endforeach; endif; ?>

    I’m not sure exactly why it is flawed. Anyone have any ideas?

  • The topic ‘Output not as expected using php on page template.’ is closed to new replies.