WordPress.org

Ready to get started?Download WordPress

Forums

Authors List with Specific Post Count (1 post)

  1. AJ Troxell
    Member
    Posted 1 year ago #

    I am currently using this to print a list of all authors who have 1 or more posts that are published. But my code fails to output the website, facebook, or twitter information. Can anyone help me figure out what is wrong here?

    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 "<a class=\"authname\" href=\"".get_bloginfo('url')."/author/";
    	the_author_meta('user_nicename', $author->ID);
    	echo "/\">";
    	the_author_meta('display_name', $author->ID);
    	echo "</a>";
    	echo "<br /><div class=\"authdet\">";
    	if ((get_the_author_meta('user_url', $author->ID) != '') && (get_the_author_meta('twitter', $author->ID) != '') && (get_the_author_meta('facebook', $author->ID) != ''))
    	{
    		echo "<a href=\"";
    		the_author_meta('user_url', $author->ID);
    		echo "\">Website</a>";
    
    		echo " | <a href=\"";
    		the_author_meta('twitter', $author->ID);
    		echo "\">Twitter</a>";
    
    		echo " | <a href=\"";
    		the_author_meta('facebook', $author->ID);
    		echo "\">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 "\">Website</a>";
    
    		echo " | <a href=\"";
    		the_author_meta('twitter', $author->ID);
    		echo "\">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 "\">Website</a>";
    
    		echo " | <a href=\"";
    		the_author_meta('facebook', $author->ID);
    		echo "\">Facebook</a><br />";
    	}
    	elseif ((get_the_author_meta('twitter', $author->ID) != '') && (get_the_author_meta('facebook', $author->ID) != ''))
    	{
    		echo "<a href=\"";
    		the_author_meta('twitter', $author->ID);
    		echo "\">Twitter</a>";
    
    		echo " | <a href=\"";
    		the_author_meta('facebook', $author->ID);
    		echo "\">Facebook</a><br />";
    	}
    	else
    	{
    	}
    	echo "<a href=\"".get_bloginfo('url')."/author/";
    	the_author_meta('user_nicename', $author->ID);
    	echo "/\">";
    	the_author_meta('display_name', $author->ID);
    	echo "'s Profile";
    	echo "</a>";
    	echo "</div></div>";
    	echo "</li>";
    	}
    	}
    }

Topic Closed

This topic has been closed to new replies.

About this Topic