• I’m having an issue with how admins are displayed on this page:
    Incorrect example

    Here’s an example of it working properly:
    correct link

    The code below is supposed to work like this: for each author, check if they are NOT an administrator. If they are not an administrator, display their bio information (picture, name, description, etc.). If they ARE an administrator, display the basic Immigration Team Info (from the correct link above).

    For some reason, when there are multiple authors, it doesn’t display properly. But when the only author is an administrator, it DOES work properly. Any advice would be appreciated!

    My Code:

    <?php
    if ( !has_category('i-am')  ) {
      echo '
        <section class="author-content">
          <hr>
          <h2 class="cta">For more information, please contact:</h2>
      ';
      if ( function_exists( 'coauthors_posts_links' ) ) {
        global $post;
          foreach( get_coauthors() as $coauthor ): 
            $authorID = $coauthor->ID;
            $authorName = $coauthor->user_firstname . " " . $coauthor->user_lastname;
            $authorFname = $coauthor->user_firstname;
            $authorPicLoc = get_user_meta($authorID, 'shr_pic', true);           
            $authorPicture = wp_get_attachment_url($authorPicLoc);
            $authorEmail = $coauthor->user_email;
            $authorDescription = $coauthor->description;
            $authorPosts = get_author_posts_url($authorID);
            $authorFullBio = $coauthor->user_url;
            $authorLinkedIn = $coauthor->linkedin; // outputs the linkedin url
            $authorRole = get_author_role($authorID);
    
            if ($authorRole != 'administrator') { ?>
              <div class="author-item">
                <img src="<?php echo $authorPicture;?>" alt="<?php echo $authorFname;?>'s headshot" />
                <div class="author-info">
                  <h3 class="author-name"><?php echo $authorName;?></h3>
                  <p class="author-description"><?php echo $authorDescription;?></p>
                  <ul class="social-media">
                    <li><a href="<?php echo $authorPosts;?>">All Posts</a></li>
                    <li><a href="<?php echo $authorFullBio;?>" target="_blank">Full Bio</a></li>
                    <li><a href="mailto:<?php echo $authorEmail;?>">Email</a></li>
                    <?php if ( $authorLinkedIn != '' ){
                      echo '<li><a href="'.$authorLinkedIn.'" target="_blank">LinkedIn</a></li>';
                    };?>
                  </ul>
                </div>
              </div> <?php
            }
            elseif ( $authorRole = 'administrator' ) { ?>
              <div class="author-item">
                <img src="/wp-content/uploads/2015/02/Favicon.jpg" alt="Buchanan Ampersand" />
                <div class="author-info">
                  <h3 class="author-name">Buchanan Immigration Team</h3>
                  <ul class="social-media">
                    <li><a href="<?php echo $authorPosts;?>">All Posts</a></li>
                    <li><a href="/contact">Contact Us</a></li>
                  </ul>
                </div>
              </div> <?php
            }
    
          endforeach;
      }
      echo '<hr></section>';
    }
    
    ?>

    The page I need help with: [log in to see the link]

  • The topic ‘Custom article footers based on author/admins’ is closed to new replies.