You may need to pass a parameter to the function when inside a custom select query. Check the functions source code in the plugin file. It problably requires a post ID, which may not be getting passed automatically in the custom query.
Also having this problem using WP_Query where it works fine on single posts but not on archive pages. 🙁
I’m using this to call multiple categories on my index:
<?php $recent = new WP_Query(“cat=871,8&showposts=6”); while($recent->have_posts()) : $recent->the_post();?>
Switching
<?php the_author_image(); ?><?php the_author_posts_link() ?>
to
<?php the_author_image( get_user_meta(‘ID’) ); ?><?php the_author_posts_link() ?>
doesn’t seem to fix it. Now sure how to do #1.
If you are using WP_Query directly, call $query->the_post() to setup the global $post variable (which the_author_image needs to work properly in this case).
Something like this should work.
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) : $the_query->the_post();
the_author_image();
endwhile;
wp_reset_postdata();
Thanks Jeff, but I’m a little confused about how to implement it properly without breaking what I already have. When I add
<?php $the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) : $the_query->the_post();
the_author_image();
endwhile;
wp_reset_postdata();?>
under
<?php $recent = new WP_Query("cat=871,8&showposts=6"); while($recent->have_posts()) : $recent->the_post();?>
it stops the page from grabbing from a specific category and just shows the same post over and over again without the author image displayed.
[Please post code or markup snippets between backticks or use the code button.]
The code is not intended to be “cut-n-paste”. You have a proper WP_Query loop already so your problem is somewhere else.