我花了几个小时试图找到解决这个问题的方法,但我无法找到答案。我有一个显示用户数据的表,我正在尝试向其中添加分页。
我曾尝试在数组中添加“paged”,但当我单击链接时,会得到“Page not found”。
如果我理解正确,那么问题是因为我生成了一个表而不是“调用”帖子。
以下是我现在拥有的:
<?php if ( !function_exists(\'gb_is_user_merchant_role\') || !gb_is_user_merchant_role( array( \'deal_admin\' ) ) ): ?>
<div class="dashboard_container section main_block">
<?php
// Purchase history
if ( gb_account_merchant_id() ) {
$deals = null;
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$args = array(
\'post_type\' => gb_get_deal_post_type(),
\'post__in\' => gb_get_merchants_deal_ids(gb_account_merchant_id()),
\'post_status\' => \'publish\',
\'gb_bypass_filter\' => TRUE,
\'posts_per_page\' => 5, // return this many
\'paged\' => $paged,
\'tax_query\' => array(
array(
\'taxonomy\' => gb_get_deal_cat_slug(),
\'field\' => \'id\',
\'terms\' => array( 81,82,83,84,85,86,87,88,89,90,91,92 ),
\'operator\' => \'NOT IN\',
),
),
);
if ( isset( $_GET[\'filter\'] ) && $_GET[\'filter\'] != \'-1\' ) {
$args[\'tax_query\'][] = array(
\'taxonomy\' => gb_get_deal_cat_slug(),
\'field\' => \'id\',
\'terms\' => array( $_GET[\'filter\'] ),
);
}
$deals = new WP_Query($args);
if ($deals->have_posts()) {
?>
<?php if ( !function_exists(\'gb_is_user_merchant_role\') || !gb_is_user_merchant_role( array( \'coupon_admin\' ) ) ): ?>
<span class="specialLink_here" style="font-size:16px;"><a href="<?php gb_merchant_purchases_report_url( gb_account_merchant_id() ) ?>" class="report_button"><?php gb_e(\'Purchase History\') ?></a> | </span>
<?php if ( function_exists( \'gb_sales_summary_report_url\' ) ): ?>
<span class="specialLink_here" style="font-size:16px;"><a href="<?php gb_sales_summary_report_url() ?>" class="report_button"><?php gb_e(\'Sales Summary Report\') ?></a> | </span>
<?php endif ?>
<?php endif ?>
<?php if ( !function_exists(\'gb_is_user_merchant_role\') || gb_is_user_merchant_role( array( \'merchant_admin\', \'sales_admin\' ) ) ): ?>
<?php if ( function_exists( \'sec_get_users_report_url\' ) ): ?>
<span class="specialLink_here" style="font-size:16px;"><a href="<?php echo sec_get_users_report_url() ?>" class="report_button"><?php gb_e(\'Customer Report\') ?></a></span>
<?php endif ?>
<?php endif ?>
<table class="report_table merchant_dashboard" style="margin-top:20px;"><!-- Begin .purchase-table -->
<thead>
<tr>
<th class="contrast th_status" style="padding:10px;"><?php gb_e(\'Status\'); ?> </th>
<th class="purchase-purchase_deal_title-title contrast" style="padding:10px;"><?php gb_e(\'Deal\'); ?></th>
<th class="contrast th_total_sold" style="padding:10px;"><?php gb_e(\'Total Sold\'); ?></th>
<th class="contrast th_published" style="padding:10px;"><?php gb_e(\'Published\'); ?></th>
<th class="contrast th_category" style="padding:10px;">
<form action="" method="get" >
<?php
$selected = ( isset( $_GET[\'filter\'] ) && $_GET[\'filter\'] != \'\' ) ? $_GET[\'filter\'] : 0 ;
$args = array(
\'show_option_none\' => gb__(\'Category Filter\'),
\'orderby\' => \'name\',
\'hide_empty\' => 1,
\'exclude\' => \'81,82,83,84,85,86,87,88,89,90,91,92\', // comma separated list of ids.
\'echo\' => 0,
\'name\' => \'filter\',
\'selected\' => $selected,
\'taxonomy\' => gb_get_deal_cat_slug() );
$select = wp_dropdown_categories( $args );
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange=\'return this.form.submit()\'>", $select);
echo $select;
?>
<noscript><div><input type="submit" value="View" /></div></noscript>
</form>
</th>
<th class="contrast th_reports" style="padding:10px;"><?php gb_e(\'Reports\'); ?></th>
</tr>
</thead>
<tbody>
<?php
while ($deals->have_posts()) : $deals->the_post();
// Build an array of the deal\'s categories.
$category_array = array();
$cats = gb_get_deal_categories( get_the_ID() );
foreach ( $cats as $cat ) {
$category_array[] = \'<a href="\'.get_term_link( $cat->slug, gb_get_deal_cat_slug() ).\'">\'.$cat->name.\'</a>\';
} ?>
<tr id="published_deal_<?php the_ID() ?>">
<td class="td_status">
<?php if ( !function_exists(\'gb_is_user_merchant_role\') || !gb_is_user_merchant_role( array( \'sales_admin\' ) ) || ( gb_is_user_merchant_role( array( \'sales_admin\' ) ) && in_array( gb_get_status(), array( \'open\', \'closed\' ) ) ) ): ?>
<span class="alt_button<?php if (gb_get_status() == \'closed\') echo \' contrast_button\' ?>"><a href="<?php the_permalink() ?>"><?php echo gb_get_status() ?></a></span>
<br/>
<?php if ( !function_exists(\'gb_is_user_merchant_role\') || !gb_is_user_merchant_role( array( \'coupon_admin\', \'sales_admin\' ) ) ): ?>
<a href="#" class="deal_suspend_button alt_button contrast_button" rel="<?php the_ID() ?>"><?php gb_e(\'Suspend\') ?></a>
<?php endif ?>
<?php endif ?>
</td>
<td class="purchase_deal_title">
<?php the_title() ?>
<br/>
<a href="<?php the_permalink() ?>" target="_blank"><?php gb_e(\'View Deal\') ?></a>
<?php if ( !function_exists(\'gb_is_user_merchant_role\') || !gb_is_user_merchant_role( array( \'coupon_admin\', \'sales_admin\' ) ) ): ?>
<a href="<?php gb_deal_edit_url() ?>" target="_blank"><?php gb_e(\'Edit\') ?></a>
<?php endif ?>
</td>
<td class="td_total_sold"><?php gb_number_of_purchases() ?></td>
<td class="td_published"><p><?php printf( gb__(\'Published: %s\'), get_the_date() ) ?></p><p><?php printf( gb__(\'Modified: %s\'), get_the_modified_date() ) ?></p></td>
<td class="td_category"><?php echo implode( \', \', $category_array ) ?></td>
<td class="td_reports">
<?php if ( !function_exists(\'gb_is_user_merchant_role\') || !gb_is_user_merchant_role( array( \'coupon_admin\' ) ) ): ?>
<span class="report_button"><?php gb_merchant_purchase_report_link() ?></span>
<?php endif ?>
<span class="report_button"><?php gb_merchant_voucher_report_link() ?></span>
</td>
</tr>
<?php
endwhile; ?>
</tbody>
</table><!-- End .purchase-table -->
<?php
} else {
echo \'<p>\'.gb__(\'No sales info.\').\'</p>\';
}
} else {
echo \'<p>\'.gb__(\'Restricted to Businesses.\').\'</p>\';
}
?>
<?php if ( $deals->max_num_pages > 1 ) : ?>
<div id="nav-below" class="navigation clearfix">
<div class="nav-previous"><?php next_posts_link( gb__( \'<span class="meta-nav">←</span> Older deals\' ), $deals->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( gb__( \'Newer deals <span class="meta-nav">→</span>\' ), $deals->max_num_pages ); ?></div>
</div><!-- #nav-below -->
<?php endif; ?>
<?php wp_reset_query(); ?>