WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Making a list of authors with a little bit extra (8 posts)

  1. CiberBlog
    Member
    Posted 1 year ago #

    Alright so this is what I'm trying to do:

    I have made a page called "Authors" where on it, it lists all the authors of the blog. However, I want to add in a few extra things into it. the two things i want to add into this list are the title of that blogger (being their work title, like manager or something), which is a custom made field which i made without issue and I can pull it up with php code. the other thing i want to put in is the first few words of that author's bio.

    so the list would look something like this:

    Author 1
    Title of author 1
    first few words of bio

    Author 2
    Title of author 2
    first few words of bio

    and so on...

    Does anybody know how to do this?

  2. keesiemeijer
    moderator
    Posted 1 year ago #

  3. CiberBlog
    Member
    Posted 1 year ago #

    I made this field with the add-on Juiz User Custom Meta (http://wordpress.org/extend/plugins/juiz-user-custom/)

    The issue I'm having is that I don't know how to make the list show up as I want it. I'm new to php so I don't know how to make an efficient looping kind of process for this.

  4. keesiemeijer
    moderator
    Posted 1 year ago #

    Try it with something like this:

    <?php
    $blogauthors = get_users();
    
    foreach($blogauthors as $author) {
    	// show display name
    	echo '<h2>Author: <a href="'.get_author_posts_url( $author->ID ).'">' . $author->display_name . '</a></h2>';
    
    	$author_meta = get_user_meta($author->ID, '');
    
    	// show profession
    	if(isset($author_meta['juiz_your_profession'][0]) && $author_meta['juiz_your_profession'][0]) {
    		echo '<p>Profession: ' .  $author_meta['juiz_your_profession'][0] . '</p>';
    	}
    
    	// show first 20 words off Biographical Info
    	if(isset($author_meta['description'][0]) && $author_meta['description'][0]) {
    		echo '<p>Description:<br/>' .  wp_trim_words( $author_meta['description'][0], 20) . '</p>';
    	}
    }
    ?>

    In the plugin I used "profession" for label and "your_profession" for Slug of field.

  5. CiberBlog
    Member
    Posted 1 year ago #

    That worked perfectly, thank you so much!

  6. keesiemeijer
    moderator
    Posted 1 year ago #

    You're welcome. Glad you got it resolved

  7. CiberBlog
    Member
    Posted 1 year ago #

    Just encountered another problem...
    How do I make it so that only if you have the role contributor appear? or is there a way so that i can just exclude the ID's of the ones that I don't want there?

    I looked around these forums, but none of the answers I could find worked on mine.

  8. keesiemeijer
    moderator
    Posted 1 year ago #

    see: http://codex.wordpress.org/Function_Reference/get_users
    change this :

    $blogauthors = get_users();

    to this:

    $blogauthors = get_users('role=contributor');

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.