Created
June 14, 2013 17:06
-
-
Save ajtroxell/5783587 to your computer and use it in GitHub Desktop.
A Better Wordpress Authors Page, tutorial at http://ajtroxell.com.dev/a-better-wordpress-authors-page/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adding custom fields to the user profile | |
function profile_contact_fields( $contactmethods ) { | |
// Twitter Field | |
$contactmethods['twitter'] = 'Twitter ID'; | |
// Facebook Field | |
$contactmethods['facebook'] = 'Facebook URL'; | |
return $contactmethods; | |
} | |
add_filter('user_contactmethods','profile_contact_fields',10,1); | |
// end of adding custom fields to the user profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function contributors() { | |
global $wpdb; | |
$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users WHERE display_name <> 'admin' ORDER BY display_name"); | |
foreach ($authors as $author ) { | |
echo "<li>"; | |
echo "<a href=\"".get_bloginfo('url')."/author/"; | |
the_author_meta('user_nicename', $author->ID); | |
echo "/\">"; | |
echo get_avatar($author->ID); | |
echo "</a>"; | |
echo '<div>'; | |
echo "<a href=\"".get_bloginfo('url')."/author/"; | |
the_author_meta('user_nicename', $author->ID); | |
echo "/\">"; | |
the_author_meta('display_name', $author->ID); | |
echo "</a>"; | |
echo "<br />"; | |
echo "Website: <a href=\""; | |
the_author_meta('user_url', $author->ID); | |
echo "/\" target='_blank'>"; | |
the_author_meta('user_url', $author->ID); | |
echo "</a>"; | |
echo "<br />"; | |
echo "Twitter: <a href=\"http://twitter.com/"; | |
the_author_meta('twitter', $author->ID); | |
echo "\" target='_blank'>"; | |
the_author_meta('twitter', $author->ID); | |
echo "</a>"; | |
echo "<br />"; | |
echo "<a href=\"".get_bloginfo('url')."/author/"; | |
the_author_meta('user_nicename', $author->ID); | |
echo "/\">Visit "; | |
the_author_meta('display_name', $author->ID); | |
echo "'s Profile Page"; | |
echo "</a>"; | |
echo "</div>"; | |
echo "</li>"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Authors List Function */ | |
function contributors() { | |
global $wpdb; | |
$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users WHERE display_name <> 'admin' AND ID <> '57' ORDER BY display_name"); | |
$post_count = get_usernumposts($author->ID); | |
foreach ($authors as $author ) | |
{ | |
if (get_usernumposts($author->ID) >= 1){ | |
echo "<li>"; | |
echo get_avatar($author->ID); | |
echo '<div>'; | |
echo "<span class=\"authname\">"; | |
the_author_meta('display_name', $author->ID); | |
echo "</span>"; | |
echo "<br /><div class=\"authdet\">"; | |
if (get_the_author_meta('user_url', $author->ID) != '' AND get_the_author_meta('twitter', $author->ID) != '' AND get_the_author_meta('facebook', $author->ID) != '') | |
{ | |
echo "<a href=\""; | |
the_author_meta('user_url', $author->ID); | |
echo "\" target=\"new\">Website</a>"; | |
echo " | <a href=\"http://twitter.com/"; | |
the_author_meta('twitter', $author->ID); | |
echo "\" target=\"new\">Twitter</a>"; | |
echo " | <a href=\""; | |
the_author_meta('facebook', $author->ID); | |
echo "\" target=\"new\">Facebook</a><br />"; | |
} | |
elseif (get_the_author_meta('user_url', $author->ID) != '' && get_the_author_meta('twitter', $author->ID) != '') | |
{ | |
echo "<a href=\""; | |
the_author_meta('user_url', $author->ID); | |
echo "\" target=\"new\">Website</a>"; | |
echo " | <a href=\"http://twitter.com/"; | |
the_author_meta('twitter', $author->ID); | |
echo "\" target=\"new\">Twitter</a><br />"; | |
} | |
elseif (get_the_author_meta('user_url', $author->ID) != '' && get_the_author_meta('facebook', $author->ID) != '') | |
{ | |
echo "<a href=\""; | |
the_author_meta('user_url', $author->ID); | |
echo "\" target=\"new\">Website</a>"; | |
echo " | <a href=\""; | |
the_author_meta('facebook', $author->ID); | |
echo "\" target=\"new\">Facebook</a><br />"; | |
} | |
elseif (get_the_author_meta('twitter', $author->ID) != '' && get_the_author_meta('facebook', $author->ID) != '') | |
{ | |
echo "<a href=\"http://twitter.com/"; | |
the_author_meta('twitter', $author->ID); | |
echo "\" target=\"new\">Twitter</a>"; | |
echo " | <a href=\""; | |
the_author_meta('facebook', $author->ID); | |
echo "\" target=\"new\">Facebook</a><br />"; | |
} | |
elseif (get_the_author_meta('user_url', $author->ID) != '') | |
{ | |
echo "<a href=\""; | |
the_author_meta('user_url', $author->ID); | |
echo "\" target=\"new\">Website</a><br />"; | |
} | |
elseif (get_the_author_meta('twitter', $author->ID) != '') | |
{ | |
echo "<a href=\"http://twitter.com/"; | |
the_author_meta('twitter', $author->ID); | |
echo "\" target=\"new\">Twitter</a><br />"; | |
} | |
elseif (get_the_author_meta('facebook', $author->ID) != '') | |
{ | |
echo "<a href=\""; | |
the_author_meta('facebook', $author->ID); | |
echo "\" target=\"new\">Facebook</a><br />"; | |
} | |
else | |
{ | |
} | |
echo "<a href=\"".get_bloginfo('url')."/author/"; | |
the_author_meta('user_nicename', $author->ID); | |
echo "/\">"; | |
echo "Biography and Archives"; | |
echo "</a>"; | |
echo "</div></div>"; | |
echo "</li>"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment