Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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
Wordpress 我想这样设计我的循环:_Wordpress_Loops_Posts - Fatal编程技术网

Wordpress 我想这样设计我的循环:

Wordpress 我想这样设计我的循环:,wordpress,loops,posts,Wordpress,Loops,Posts,我有一个循环代码,显示第一篇文章有缩略图,而其他文章不包含缩略图的文章。但我想把它放在一个特定的类别中 我的循环如下所示: <div class="category"> <ul> <!-- Start the Loop. --> <?php $i = 1 ; ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <!--

我有一个循环代码,显示第一篇文章有缩略图,而其他文章不包含缩略图的文章。但我想把它放在一个特定的类别中
我的循环如下所示:

    <div class="category">
    <ul>
<!-- Start the Loop. -->
 <?php $i = 1 ; ?>
 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
 <!-- Display the Title as a link to the Post's permalink. -->
 <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php if ($i == 1): ?>
<?php the_post_thumbnail();?>
<?php endif; ?>
<?php $i++; endwhile; endif; ?>
</ul>
</div>


因此,我想按具有相同样式的特定类别显示此代码。

请在您的文件中尝试此代码

<?php $catquery = new WP_Query( 'cat=72&posts_per_page=-1' );  ?>

    <ul>
        <?php 
            while($catquery->have_posts()) : $catquery->the_post(); 
        ?>
            <li><h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
            <li><?php the_content(); ?></li>
        <ul>
        <?php endwhile; ?> 
    </ul>
<?php wp_reset_postdata(); ?>


您可以分享更多详细信息吗。它是自定义注册分类法还是默认分类法?你想在这里设置哪个类别。我将在那里定义任何类别id。。我只需要代码..但我需要有人修改我的代码..在我的代码中,我可以通过粘贴此代码来指定类别吗?只需粘贴我的代码并更改id 72而不是您我的代码中有一种否定的风格..mu loop设计第一篇文章带有缩略图,其他5篇文章没有任何标题..我想要那样..你明白吗?