Realisiert werden soll die Anzeige von Autoreninformationen in der Einzelansicht von Beiträgen ohne Plugin. Folgende Punkte sollen angezeigt bzw. beachtet werden:
- Links zur Website des Autors und ggf. sozialen Netzwerken, sofern diese Informationen im Profil angegeben sind
- bisher verfasste Beiträge verlinkt mit dem individuellen Archiv des Autoren
- Ausgabe des Website-Namens im Text via Abfrage, damit die Lösung variabel einsetzbar ist
Über die functions.php oder via Plugin werden benutzerdefinierte Autorenangaben möglich. In einer Multisite-Umgebung präferiere ich den Einsatz dieser Kontaktangaben netzwerkweit, also über ein Must-Use-plugin zu definieren. Zur Übersichtlichkeit auf der Profil-Seite werden dort zunächst AIM, Jabber und YIM deaktiviert.
function custom_contactmethods( $contactmethods ) {
unset($contactmethods['aim']);
unset($contactmethods['jabber']);
unset($contactmethods['yim']);
$contactmethods['twitter'] = 'Twitter';
$contactmethods['facebook'] = 'Facebook';
$contactmethods['xing'] = 'XING';
return $contactmethods;
}
add_filter('user_contactmethods','custom_contactmethods',10,1);
single.php
<div class="postauthor">
<p class="postauthorabout">Über den Autor<p>
<h2><?php the_author(); ?></h2>
<p class="postauthorbio"><?php if(get_the_author_meta('description') != NULL) { ?><?php the_author_meta('description'); ?> <?php } ?>
Auf <?php bloginfo('name'); ?> stammen <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>" title="Alle Beiträge von <?php the_author(); ?>"><?php the_author_posts(); ?> Beiträge</a> aus der Feder von <?php the_author_meta('user_firstname'); ?>.</p>
<p class="postauthorlinks">
<?php if(get_the_author_meta('user_url') != NULL) { ?><a href="<?php the_author_meta('user_url'); ?>">Website</a> <?php } ?>
<?php if(get_the_author_meta('facebook') != NULL) { ?><a href="<?php the_author_meta('facebook'); ?>">Facebook</a> <?php } ?>
<?php if(get_the_author_meta('twitter') != NULL) { ?><a href="<?php the_author_meta('twitter'); ?>">Twitter</a> <?php } ?>
<?php if(get_the_author_meta('xing') != NULL) { ?><a href="<?php the_author_meta('xing'); ?>">XING</a> <?php } ?>
</p>
</div>
style.css
.postauthorabout { font-size:0.8em; }
.postauthorabout, .postauthorlinks { font-variant:small-caps; }
.postauthorbio { margin:0 0 0.8em 0; }
.postauthorlinks { font-weight:bold; }
.postauthorlinks a { margin:0 0.4em 0 0; }
Ergebnis
So kann das Ganze dann aussehen: