Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WordPress限制类别页面中的帖子_Php_Wordpress_Loops - Fatal编程技术网

Php WordPress限制类别页面中的帖子

Php WordPress限制类别页面中的帖子,php,wordpress,loops,Php,Wordpress,Loops,这是我的WordPress循环代码…:) 未找到任何物品 正如您所看到的,我有一些条件,因为是_category('instagram') 问题是:我需要在确切的类别中限制帖子数量,而不是完全限制它们。 我怎样才能做到这一点呢?我不确定我们是否能用wordpress的方式做到这一点。。但这里是解决办法-- $no_of_posts=5; $post_counter=0; 如果(is_类别('instagram')&($no_帖子) <?php if(have_posts()) : ?&

这是我的WordPress循环代码…:)


未找到任何物品

正如您所看到的,我有一些条件,因为
是_category('instagram')

问题是:我需要在确切的类别中限制帖子数量,而不是完全限制它们。

我怎样才能做到这一点呢?

我不确定我们是否能用wordpress的方式做到这一点。。但这里是解决办法--

$no_of_posts=5;
$post_counter=0;
如果(is_类别('instagram')&($no_帖子)
<?php if(have_posts()) : ?>
        <?php while(have_posts()) : the_post(); ?>
        <?php if (is_category('instagram')) {?>

        <?php
            $__width = '225';
            $__height = '225';
        ?>
            <div id="instagram-photos">
                <a href="<?php the_permalink() ?>"class="instagram-photo">
                <div class="photo"><?php custom_get_post_attachments(get_the_ID(), $__width, $__height, get_the_title()); ?>    </div>
                </a>
            </div>

            <?php }elseif(is_category('runway')) { ?>
            <?php
            $__width = '298';
            $__height = '500';
            ?>
            <div id="runway-category">
                <a href="<?php the_permalink() ?>" class="runway-category-posts">
                <div class="photo"><?php custom_get_post_attachments(get_the_ID(), $__width, $__height, get_the_title()); ?><div class="runway-title"><?php the_title(); ?></div></div>
                </a>            
            </div>
            <?php } elseif(is_category('')){?>
        <article <?php post_class(); ?>>
                    <div class="latest-posts">
                    <div class="latest-posts-info">
                    <div class="title"><h1><?php the_title(); ?><h1></div>
                    <div class="text">
                    <?php the_excerpt(); ?>
                    </div>
                    <div class="post-share">
                        <div class="facebook-like" style="float:left;">
                            <a href="http://www.facebook.com/sharer.php?u=<?php the_permalink() ?>" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/images/facebook-icon.png" /></a>
                        </div>
                        <div class="twitter-follow" style="float:left;">
                            <a href="http://twitter.com/share?text=<?php the_title(); ?>&url=<?php the_permalink() ?>" target="_blank" ><img src="<?php echo get_template_directory_uri(); ?>/images/twitter-icon.png" /></a>
                        </div>
                        <div class="google-share">
                            <a href="https://plus.google.com/share?url=<?php the_permalink() ?>" target="_blank" ><img src="<?php echo get_template_directory_uri(); ?>/images/google-icon.png" /></a>
                        </div>
                    </div>
                    <div class="clear"></div><div class="post-read-more"><a href="<?php the_permalink() ?>" class="read-more">Read More</a></div>
                    <div class="clear"></div>
                </div>
                <div class="latest-posts-img">
                    <?php //echo get_the_post_thumbnail(); ?>
                    <?php custom_get_post_attachments(get_the_ID(), $__width, $__height, get_the_title()); ?>                   
                </div>
                <div class="clear"></div>
                </div>
        </article>
        <?php }?>
        <?php endwhile; else: ?>
        <div class="content">
        <p class="not-found-p">No articles found!</p>
        </div>
        <?php endif; ?>
$no_of_posts = 5;

$post_counter = 0;

if(is_Category('instagram') && ($no_of_posts<=$post_counter)) {
// bunch of code 
$post_counter++;
}