• I’m currently dislpaying a list of subscribers to my blog. The results are displayed vertically in a column like displayed below. I would like to display the results horizontally in a row, with 4 results per row. I need help with the code for the looping and formatting. The code I’m using now is below:

    |———-|
    | |
    | |
    | PIC |
    | |
    | |
    ————

    |———-|
    | |
    | |
    | PIC |
    | |
    | |
    ————

    |———-|
    | |
    | |
    | PIC |
    | |
    | |
    ————

    <?php

    // Get the authors from the database ordered by user nicename
    global $wpdb;
    $query = “SELECT ID, user_nicename from $wpdb->users ORDER BY user_nicename”;
    $author_ids = $wpdb->get_results($query);

    // Loop through each author
    foreach($author_ids as $author) :

    // Get user data
    $curauth = get_userdata($author->ID);

    // If user level is above 0 or login name is “admin”, display profile
    if($curauth->user_level == 0) :

    // Get link to author page
    $user_link = get_author_posts_url($curauth->ID);

    // Set default avatar (values = default, wavatar, identicon, monsterid)
    $avatar = ‘wavatar’;
    ?>

    <div class=”post”>

    ” title=”<?php echo $curauth->display_name; ?>”>
    <?php echo get_avatar($curauth->user_email, ’96’, $avatar); ?>

    <h3 class=”post-title”>
    ” title=”<?php echo $curauth->display_name; ?>”><?php echo $curauth->display_name; ?>
    </h3>

    <p>
    <?php echo $curauth->description; ?>
    </p>

    </div>

    <?php endif; ?>

    <?php endforeach; ?>

    Thanks in Advance!

  • The topic ‘Display Results in Rows’ is closed to new replies.