-1
我有不同的自定义分类法中的帖子。我需要在页面中显示一个分类的帖子。现在我可以在单个页面中获取所有分类法中的所有帖子。我有一个分类的foreach循环,在循环内部,与该分类相对应的所有帖子都通过post方法显示。我之前从未使用过分页。我如何在这种情况下添加分页? 我下面封闭如何在wordpress中添加分页
<div class="main">
<section class="brands-sec product-sec">
<div class="container">
<?php
$siteurl = home_url('/');
$tax = 'product'; // slug of taxonomy
$terms = get_terms($tax);
foreach ($terms as $term) {
$id = $term->term_id;
$slug = $term->slug;
$description = $term->description;
$image_url = z_taxonomy_image_url($id, NULL, TRUE); // category image display
$link = "<a href='$siteurl?$tax=$slug' ><h1> $term->name </h1></a>";
echo '<img src="' . $image_url . '">'; ?>
<div class="col-md-8 pull-right col-sm-10 pull-right col-xs-12 brnd prdct">
<img src="<?php echo $image_url ; ?>" class="img-responsive pdt-logo" alt="loyd"/>
<div class="brand-logos pdt">
<p><?php echo $description ; ?></p>
<h4>Product</h4>
<?php $args = array("posts_per_page" => "-1", "product"=>$slug ,"post_type" => "products");
$posts = get_posts($args);
foreach($posts as $data){
$thumb = wp_get_attachment_url(get_post_thumbnail_id($data ->ID));
$custom_fonts = get_post_custom($data->ID);$custom_fonts_key= $custom_fonts['category'];$custom_fonts_array = $custom_fonts_key[0]; ?>
<div class="row mb40">
<div class="col-md-4 col-sm-4 col-xs-12 brand-single product-single">
<img src="<?php echo $thumb; ?>" class="img-responsive" alt="allegro products"/>
<h5><?php echo $data->post_title; ?></h5>
<p><?php echo $data->post_content; ?></p>
</div>
<div class="col-md-8 col-sm-8 col-xs-12 brand-single product-detail">
<ul class="products">
<?php
$attachments = new Attachments('my_attachments',$data->ID); /* pass the instance name */ ?>
<?php if($attachments->exist()) : ?>
<?php while($attachments->get()) : ?>
<li><img src="<?php echo $attachments->url(); ?>" class="img-responsive" alt="allegro products"/></li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
</div>
<?php } ?>
</div><!--end brand-logos-->
</div><!--end brnd-->
<?php } ?>
</div>
我的代码以下产品自定义分类。在那里有不止一个术语说loyd,Nycofee,....在这两个术语中都有不止一个帖子。我需要在一页中显示loyd中的帖子,在下一页中显示ncofee。如何在这种情况下添加分页?
它显示完整列表。我怎么用这个? – Ranju
你可以检查这个网址http://callmenick.com/post/custom-wordpress-loop-with-pagination –
我已经添加了我的代码。你能帮我吗? – Ranju