Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.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/3/html/82.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_Html_Wordpress_Loops - Fatal编程技术网

Php Wordpress-以自定义方式显示最后一篇文章

Php Wordpress-以自定义方式显示最后一篇文章,php,html,wordpress,loops,Php,Html,Wordpress,Loops,我是wordpress的新手。我有一个任务显示最后3篇文章,但不是用通常的方式。邮政部门将有不同的大小。这是我的html代码 <div class="latest-posts"> <div class="latest-posts-news-left">NEWS</div> <div class="latest-posts-news-right"> <div class="l">

我是wordpress的新手。我有一个任务显示最后3篇文章,但不是用通常的方式。邮政部门将有不同的大小。这是我的html代码

<div class="latest-posts">
       <div class="latest-posts-news-left">NEWS</div>
       <div class="latest-posts-news-right">
           <div class="l">
               <div class="latest-posts-news-first">first post</div>
               <div class="latest-posts-news-second">second post</div>
           </div>
           <div class="r">
               <div class="latest-posts-news-third">third post</div>
           </div>
       </div>
</div>

新闻
第一个职位
第二职位
第三职位
这是向您展示它的外观的图像

所以左边两个div,右边一个更长的div

我该如何处理这个案子?如果你能给我一个有效的例子,我将不胜感激,因为我正在寻找答案,但没有找到

非常感谢


<?php
$queryObject = new WP_Query( 'post_type=post&posts_per_page=5,orderby=post_date,order=DESC' );
// The Loop!
if ($queryObject->have_posts()) {

while ($queryObject->have_posts()) {
$queryObject->the_post();
?>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php
}

}
?>
试试这个

<?php 
// the query
$the_query = new WP_Query( 'post_type=post&posts_per_page=3,orderby=post_date,order=DESC' );
 ?>

<?php if ( $the_query->have_posts() ) : 


        $count_rows  = 0;
?>

<div class="latest-posts">
       <div class="latest-posts-news-left">NEWS</div>
       <div class="latest-posts-news-right">

  <!-- the loop -->
  <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <?php if( ( $count_rows + 1 ) % 2 == 0 ) { ?>
     <div class="l">
               <div class="latest-posts-news-first"><?php the_post(); ?></div>
               <div class="latest-posts-news-second"><?php the_post(); ?></div>
           </div>
       <?php  } else { ?>

        <div class="r">
               <div class="latest-posts-news-third"><?php the_post(); ?></div>
           </div>
  <?php } 
  $count_rows++; 
  endwhile; ?>
  <!-- end of the loop -->

</div>
</div>

  <?php wp_reset_postdata(); ?>

<?php else:  ?>
  <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

新闻


您能将您尝试过的代码显示出来吗?