0
我有一個簡單的頁面模板,名爲Memberships
。WooCommerce自定義循環分頁
我想要一個簡單的WooCommerce產品列表,每頁有50個項目。 在按鈕上,我需要一個分頁元素,它可以幫助我移動到下一個50個元素。
這是頁面模板代碼
<?php
/**
* Template Name: Memberships
*/
if (!defined('ABSPATH')) exit; // Exit if accessed directly
/**
*
* <head>
*
*/
get_template_part('partials/head', 'page');
/**
*
* Header
*
*/
get_template_part('partials/header', 'page');
/**
*
* Content
*
*/
?>
<div class="row">
<div class="category-visual focuspoint" data-focus-x="0.59" data-focus-y="0.65" data-focus-w="720"
data-focus-h="300">
<?php echo get_the_post_thumbnail($page->ID, 'full'); ?>
<div class="category-visual-text">
<h1 class="headline"><?php echo the_title(); ?></h1>
<span class="subheader"><?php echo get_post(759)->post_content; ?></span>
</div>
</div>
<?php if(wc_memberships_is_user_active_member(get_current_user_id(), 'packagecloud-membership')) {?>
<ul class="products">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 5,
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => 'packages'
),
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => 'demo-packages'
)
)
);
$loop = new WP_Query($args);
if ($loop->have_posts()) {
while ($loop->have_posts()) : $loop->the_post();
/*wc_get_template_part('content', 'product');*/
?>
<ul>
<?php the_title(); ?>
</ul>
<?php
endwhile;
} else {
echo __('No products found');
}
wp_reset_postdata();
?>
</ul>
<?php } else {
echo get_current_user_id();
} ?>
</div>
</div>
<?php
/**
*
* Footer
*
*/
get_template_part('partials/footer', 'page');
/**
*
* Foot
*
*/
get_template_part('partials/foot', 'page'); ?>
,這是output。
我嘗試了很多事情來得到分頁,沒有任何工作。它只是沒有告訴我分頁元素,或者不會將我移動到下一個元素。