Last active
April 7, 2020 01:28
-
-
Save amrinz/4bbae9dd80f5ed03973b734b5090b189 to your computer and use it in GitHub Desktop.
Displays current logged in user posts in table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
$postcount = 10; | |
$wp_query = new WP_Query( array( | |
'post_type' => 'post', | |
'posts_per_page' => $postcount, | |
'author' => get_current_user_id(), | |
'paged' => $paged | |
) ); | |
?> | |
<?php if ( $wp_query->have_posts() ): ?> | |
<div class="table-responsive"> | |
<table class="table table-striped table-borderless"> | |
<tr><th>No</th><th>Judul</td><th>Kategori</th><th>Lokasi</th></tr> | |
<?php $i = 0; while ( $wp_query->have_posts()): $wp_query->the_post(); $i++; ?> | |
<tr> | |
<td><?php if($paged >= 2) { echo (($paged*$postcount)-$postcount)+$i; } else { echo $i; } ?></td> | |
<td><a href="<?php the_permalink(); ?>" title="<?php _e('Continue reading', 'lombokmedia'); ?> <?php the_title(); ?>"><?php the_title(); ?></a></td> | |
<td><?php the_category( ' ' ); ?></td> | |
<td><?php echo get_the_term_list( get_the_ID(), 'lokasi', '', ', ', '' ); ?></td> | |
</tr> | |
<?php endwhile; ?> | |
</table> | |
</div> | |
<?php lmd_page_navi(); //my-custom page navigation | |
wp_reset_postdata(); ?> | |
<?php else: | |
get_template_part('lmd-nothing'); //template to display message no post found | |
endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For those who can't find how to display post numbering in table