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。
我尝试了很多事情来得到分页,没有任何工作。它只是没有告诉我分页元素,或者不会将我移动到下一个元素。