The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Get custom posts by user, display in a table

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #185663
    Chris Lusk

    Hey guys,
    I am building a dashboard for our employees to track open files. I created a custom post type called FILES, and about 20 metaboxes for this post type. When the user is logged in, I would like to display all of the FILES they have created or are working on and display the metabox results for each FILE in a table.

    I have the table and header row outside of the Loop, then the variables and data rows inside the Loop, then the closing table tags outside the loop, like so:

    Here is my Loop:

    $author_args = array(
                'author_name' => $current_user->display_name,
                'post_status' => 'publish',
                'post_type' => 'files'
            $author_query = new WP_Query($author_args);
            // display results from $author_query
            if ( $author_query->have_posts() ) : while ( $author_query->have_posts() ) : $author_query->the_post(); 

    Then I call my variables and have the inside of the table setup:

     <td class="text-left first-col" rowspan="3">
    <a href="<?php echo get_permalink(); ?>" ><?php the_title(); ?></a>

    Then I end the Loop, and close the Table:

    <?php endwhile; else :
        echo 'No Files found'; 
        endif; wp_reset_postdata(); ?>

    I am getting a jumbled mess in the Table if there are blank metaboxes. I am not familiar enough with using the foreach query but am I on the right track?


    Well if that is indeed all the code, you’re missing some stuff inside the while loop. You’re not closing the <td> or <tr> tags.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.