Howdy Folks,
ich habe eine Seite "Unsere Autoren" erstellt, auf der alle Autoren gelistet werden. Das klappt soweit ganz gut, allerdings würde ich auch gerne die Anzahl der Beiträge ausgeben, die jeder Autor verfasst hat. Zudem sollen die Autoren ausgeblendet werden, die bisher noch keine Beiträge verfasst haben. Wie lässt sich das bewerkstelligen?
Es geht um diese Seite: http://goo.gl/Uh5veW
Mit diesem Code frage ich die Autoren ab und gebe sie aus:
<?php
$result = $wpdb->get_results("SELECT ID, display_name FROM {$table_prefix}users ORDER BY display_name ASC");
foreach ($result as $user) {
$user_id = $user->ID;
if (get_the_author_meta('description',$user_id)) { ?>
<div class="author-info clearfix">
<div class="author_description">
<div class="author-avatar-wrap grid_2 alpha"><?php echo get_avatar(get_the_author_meta('user_email',$user_id), $size = 100, $default = '', $alt = 'Avatar'); ?></div>
<p class="author_name"><strong><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID',$user_id ) ) ?>" class="url"><?php echo get_the_author_meta( 'display_name',$user_id ) ?></a></strong></p>
<div class="author_bio"><p><?php echo wpautop(get_the_author_meta('description',$user_id)); ?></p></div>
</div>
<div class="author-meta entry clearfix">
<ul type="none">
<li><strong>Dabei seit:</strong> <?php printf( mysql2date( get_option( 'date_format' ), get_the_author_meta( 'user_registered', $user_id ) ) ); ?></li>
<?php if (get_the_author_meta('user_url',$user_id)) { ?>
<li><strong>Homepage:</strong> <a href="<?php the_author_meta('user_url',$user_id); ?>" target="_blank"><?php the_author_meta('user_url',$user_id); ?></a></li>
<?php }
if (get_the_author_meta('twitter',$user_id)) { ?>
<li><strong>Twitter:</strong> <a href="https://twitter.com/<?php the_author_meta('twitter',$user_id); ?>" target="_blank">@<?php the_author_meta('twitter',$user_id); ?></a></li>
<?php }
if (get_the_author_meta('facebook',$user_id)) { ?>
<li><strong>Facebook:</strong> <a href="https://www.facebook.com/<?php the_author_meta('facebook',$user_id); ?>" target="_blank"><?php the_author_meta('facebook',$user_id); ?></a></li>
<?php }
if (get_the_author_meta('googleplus',$user_id)) { ?>
<li><strong>Google+:</strong> <a href="https://plus.google.com/<?php the_author_meta('googleplus',$user_id); ?>" target="_blank"><?php the_author_meta('googleplus',$user_id); ?></a></li>
<?php }
if (get_the_author_meta('skype',$user_id)) { ?>
<li><strong>Skype:</strong> <a href="callto:<?php the_author_meta('skype',$user_id); ?>?userinfo"><?php the_author_meta('skype',$user_id); ?></a></li>
<?php }
if (get_the_author_meta('threema',$user_id)) { ?>
<li><strong>Threema-ID:</strong> <?php the_author_meta('threema',$user_id); ?></li>
<?php } ?>
</ul>
</div>
<div class="author-description entry clearfix">
<p>
<a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID',$user_id ) ) ?>" class="url">Alle Artikel von <?php the_author_meta('display_name',$user_id) ?> zeigen</a>
</p>
</div>
</div>
<?php }
}
?>
Alles anzeigen
Wenn jemand einen Tipp für mich hat, immer her damit. Über http://codex.wordpress.org/Template_Tags/wp_list_authors bin ich bereits gestolpert, aber entweder bin ich zu blöd dazu, oder die Funktion macht wirklich nicht das, was ich will...
Keep it Country,
Markus aka Cowboy