0

In a custom post archive; Is it possible to reduce the the number of posts shown, depending on the contents of the showing posts?

I have a custom post type for products. In the product archive there are 20 products showing on each page, 4 rows, 5 cols. In some cases where the product image is super wide I'd like that product to be shown with double width.

When showing a super wide product, I'd like to reduce the number of posts to 19 (18 if there are two super wide products). Keeping the bottom line straight.


This is the loop for my custom post archive. I got your point with numcols. And as you say, I should probably modify the query, making sure that page 2 and 3 (and on) shows the right posts.

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink(); ?>" class="produkt_item normal various" data-fancybox-type="iframe">
<?php if ( has_post_thumbnail() ) { ?>
    <div class="utvaldbild">
        <?php the_post_thumbnail('produktbild'); ?>
    </div>
<?php } ?>

<h2><?php the_title();?></h2>
<p><?php the_field('produktnotis'); ?></p>

<?php if (get_field('nedladdning')) { ?><div class="nedladdning"></div><?php } ?>
</a>
<?php endwhile; ?>
4

1 回答 1

0

您可以在您的帖子自定义 posttype 中添加一个自定义字段,称为 numcols 或类似的东西。普通产品将是 1 和超级图像 2 等。

然后只需在您的 php 代码中记录它们,并在适当的时候切断它们。

您可能可以修改查找页面中的查询来执行此操作,但我必须查看一些代码才能有所帮助。理想情况下,您的自定义产品存档页面和自定义帖子类型的定义。

于 2013-01-23T18:41:16.383 回答