<?php
/********用户资料页面********/
if(!is_user_logged_in()) {
	wp_redirect(site_url()."/wp-login.php");
	exit;
}
global $wpdb, $post, $wp_query,$userdata, $wp_http_referer;
$query_vars = $wp_query->query_vars;
//$pagenum = isset($query_vars['paged']) ? $query_vars['paged'] : 1;
$pagenum = isset( $_GET['pagenum'] ) ? intval( $_GET['pagenum'] ) : 1;
$args = array(
	'author' => get_current_user_id(),
	'post_status' => array('publish'),
	//'post_type' => 'detail',
	'posts_per_page' => 20,
	'paged' => $pagenum
);
$dashboard_query = new WP_Query( $args );
?>
<h2>总共发表文章：<?php echo $dashboard_query->found_posts;?>篇</h2>
<?php if( $dashboard_query->have_posts() ) : ?>
<ul class="item-list">
<?php while ( $dashboard_query->have_posts() ) : $dashboard_query->the_post(); ?>
<li>
<div class="item-info">
<h3>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h3>
</div>
<div class="sale-info">
<div class="rating">
  <span class="smalldesc"><a href="<?php echo site_url(); ?>/my-account/edit/<?php the_ID(); ?>">编辑</a></span>
  <span class="green"><a href="<?php echo site_url(); ?>/my-account/delete/<?php the_ID(); ?>">删除</a></span>
</div>
</div>
</li>
<?php endwhile;?>  
</ul>
<?php
endif;
?>
<?php
$pagination = paginate_links( array(
	'base' => add_query_arg( 'pagenum', '%#%' ),
	'format' => '',
	'prev_text' => '上一页',
	'next_text' => '下一页',
	'total' => $dashboard_query->max_num_pages,
	'current' => $pagenum
	)
);
if ( $pagination ) {
	echo $pagination;
}
?>