<div id="recentp">
<ul>
<li>
<div id="recentpleft">
<h1 class="name">Βασίλης</h1>
<h1 class="lname">Σαμπράκος</h1>
<h1 class="stt">
<?php
query_posts('author_name=admin&showposts=1');
if(have_posts()) : while (have_posts()) : the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h1>
</div>
<div id="recentpright">
<div id="pphoto">
<img src="http://theinsiders.gr/<?php the_author_meta('user_login'); ?>.png" width="80" height="100" border="0" />
</div>
</div>
<?php endwhile; endif; wp_reset_query(); ?>
</li>
<li>
<div id="recentpleft">
<h1 class="name">Δημήτρης</h1>
<h1 class="lname">Κωνσταντινίδης</h1>
<h1 class="stt">
<?php
query_posts('author_name=dikonst&showposts=1');
if(have_posts()) : while (have_posts()) : the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h1>
</div>
<div id="recentpright">
<div id="pphoto">
<img src="http://theinsiders.gr/<?php the_author_meta('user_login'); ?>.png" width="80" height="100" border="0" />
</div>
</div>
<?php endwhile; endif; wp_reset_query(); ?>
</li>
<li>
<div id="recentpleft">
<h1 class="name">Γιάννης </h1>
<h1 class="lname">Σερέτης</h1>
<h1 class="stt">
<?php
query_posts('author_name=seretisgian&showposts=1');
if(have_posts()) : while (have_posts()) : the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h1>
</div>
<div id="recentpright">
<div id="pphoto">
<img src="http://theinsiders.gr/<?php the_author_meta('user_login'); ?>.png" width="80" height="100" border="0" />
</div>
</div>
<?php endwhile; endif; wp_reset_query(); ?>
</li>
<li>
<div id="recentpleft">
<h1 class="name">Σταμάτης</h1>
<h1 class="lname">Γαρρής</h1>
<h1 class="stt">
<?php
query_posts('author_name=stamoschios&showposts=1');
if(have_posts()) : while (have_posts()) : the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h1>
</div>
<div id="recentpright">
<div id="pphoto">
<img src="http://theinsiders.gr/<?php the_author_meta('user_login'); ?>.png" width="80" height="100" border="0" />
</div>
</div>
<?php endwhile; endif; wp_reset_query(); ?>
</li>
</ul>
</div>
It query the first Author, but never the rest.
It works for multiple querys, if i change all usernames, to admin for example. But not for anything else, than admin
juan manuel incaurgarat answers:
you can try this
<?php
$lastnames = $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE $wpdb->usermeta.meta_key = 'support' AND $wpdb->usermeta.meta_value ='1'");
foreach ($lastnames as $userid) {
$user = get_userdata($userid);
$post_count = get_usernumposts($user->ID);
$author_posts_url = get_author_posts_url($user->ID);
echo '' . $user->ID . '';
}
?>
<?php
$ud = $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE $wpdb->usermeta.meta_key = 'suppoer' AND $wpdb->usermeta.meta_value ='1'");
echo print_r($ud) ;
?>
EDIT: you want to query post from no matter which author, right?
in your 9th line you are querying posts from the admin only
you may want to remove that in order to get posts from all the users.
like this for example:
query_posts( 'posts_per_page=5' );
Basilis Kanonidis comments:
Can you please explain more? Like
how i add it to my HTML / how i "print" specific details, as i have up to my code.
Thanks a lot
juan manuel incaurgarat comments:
try this code. is your code but corrected, so you can replace it all :)
juan manuel incaurgarat comments:
mm i attached a php file but i think the upload failed. please contact on [email protected] :)
juan manuel incaurgarat comments:
example, this code will query 5 posts (no matter which author) and loop through them writing their titles:
<?php
// The Query
query_posts( 'posts_per_page=5' );
// The Loop
while ( have_posts() ) : the_post();
echo '<li>';
the_title();
echo '</li>';
endwhile;
// Reset Query
wp_reset_query();
?>
Basilis Kanonidis comments:
Is that what i asked? Can you read?
juan manuel incaurgarat comments:
hey dude, you dont need to be rude.
you can at least explain yourself better, as the question you posted has grammatical errors:
try this to solve you problem:
<div id="recentp">
<ul>
<li>
<div id="recentpleft">
<h1 class="name">Βασίλης</h1>
<h1 class="lname">Σαμπράκος</h1>
<h1 class="stt">
<?php
query_posts( 'posts_per_page=10' );
if(have_posts()) : while (have_posts()) : the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h1>
</div>
<div id="recentpright">
<div id="pphoto">
<img src="http://theinsiders.gr/<?php the_author_meta('user_login'); ?>.png" width="80" height="100" border="0" />
</div>
</div>
<?php endwhile; endif; wp_reset_query(); ?>
</li>
<li>
<div id="recentpleft">
<h1 class="name">Δημήτρης</h1>
<h1 class="lname">Κωνσταντινίδης</h1>
<h1 class="stt">
<?php
query_posts('author_name=dikonst&showposts=1');
if(have_posts()) : while (have_posts()) : the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h1>
</div>
<div id="recentpright">
<div id="pphoto">
<img src="http://theinsiders.gr/<?php the_author_meta('user_login'); ?>.png" width="80" height="100" border="0" />
</div>
</div>
<?php endwhile; endif; wp_reset_query(); ?>
</li>
<li>
<div id="recentpleft">
<h1 class="name">Γιάννης </h1>
<h1 class="lname">Σερέτης</h1>
<h1 class="stt">
<?php
query_posts('author_name=seretisgian&showposts=1');
if(have_posts()) : while (have_posts()) : the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h1>
</div>
<div id="recentpright">
<div id="pphoto">
<img src="http://theinsiders.gr/<?php the_author_meta('user_login'); ?>.png" width="80" height="100" border="0" />
</div>
</div>
<?php endwhile; endif; wp_reset_query(); ?>
</li>
<li>
<div id="recentpleft">
<h1 class="name">Σταμάτης</h1>
<h1 class="lname">Γαρρής</h1>
<h1 class="stt">
<?php
query_posts('author_name=stamoschios&showposts=1');
if(have_posts()) : while (have_posts()) : the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h1>
</div>
<div id="recentpright">
<div id="pphoto">
<img src="http://theinsiders.gr/<?php the_author_meta('user_login'); ?>.png" width="80" height="100" border="0" />
</div>
</div>
<?php endwhile; endif; wp_reset_query(); ?>
</li>
</ul>
</div>
Gabriel Reguly answers:
Hi Basilis,
Your HTML has some minor bugs, but instead of fixing it I propose this new one.
Of course you can edit it to fit your needs ;-)
<!-- start blog directory -->
<?php
// Get the authors from the database ordered randomly
global $wpdb;
$query = "SELECT ID, user_nicename from $wpdb->users ORDER BY ID";
$author_ids = $wpdb->get_results($query);
// Loop through each author
foreach($author_ids as $author) {
// Get user data
$curauth = get_userdata($author->ID);
// Get link to author page
$user_link = get_author_posts_url($curauth->ID);
// Get blog details for the authors primary blog ID
$blog_details = get_blog_details($curauth->primary_blog);
if ($blog_details->post_count == "1") {
$postText = "post ";
}
else if ($blog_details->post_count >= "2") {
$postText = "posts";
}
else {
$postText = "posts";
}
$updatedOn = strftime("%m/%d/%Y at %l:%M %p",strtotime($blog_details->last_updated));
if ($blog_details->post_count == "") {
$blog_details->post_count = "Zero";
}
$posts = $wpdb->get_col( "SELECT ID FROM wp_".$curauth->primary_blog."_posts WHERE post_status='publish' AND post_type='post' AND post_author='$author->ID' ORDER BY ID DESC LIMIT 5");
$postHTML = "";
$i=0;
foreach($posts as $p) {
$postdetail=get_blog_post($curauth->primary_blog,$p);
if ($i==0) {
$updatedOn = strftime("%m/%d/%Y at %l:%M %p",strtotime($postdetail->post_date));
}
$postHTML .= "• <a href=\"$postdetail->guid\">$postdetail->post_title</a><br />";
$i++;
}
?>
<div class="author_bio">
<div class="row">
<div class="column grid_2"> <a href="<?php echo $blog_details->siteurl; ?>"><?php echo get_avatar($curauth->user_email, '96','http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536'); ?></a> </div>
<div class="column grid_6"> <a href="<?php echo $blog_details->siteurl; ?>" title="<?php echo $curauth->display_name; ?> - <?=$blog_details->blogname?>">
<?php //echo $curauth->display_name; ?>
<?=$curauth->display_name;?>
</a><br />
<small><strong>Updated
<?=$updatedOn?>
</strong></small><br />
<?php echo $curauth->description; ?> </div>
<?php
if ( $i > 0 ) {
?>
<div class="column grid_3">
<h3>Recent Posts</h3>
<?=$postHTML?>
</div>
<?php
}
?>
</div>
<span class="post_count"><a href="<?php echo $blog_details->siteurl; ?>" title="<?php echo $curauth->display_name; ?>">
<?=$blog_details->post_count?>
<?=$postText?>
</a></span>
</div>
<?php
}
?>
<!-- end blog directory -->
Regards,
Gabriel