I have a static page with 10 containers located at different places in the index.php file, i want to show the 10 latest posts. I want to echo the data for a post (title,text,thumbnail,author,time) like this:

       <div class="text">
         <?php
            echo '$textfrompost3';
         ?>   
    </div>

 <div class="title">
     <?php
        echo '$titlefrompost3';
     ?>   
    </div>

      ...
      ...

My PHP file:

<?php 
   // the query
   $the_query = new WP_Query( array(
     'category_name' => 'Allgemein',
      'posts_per_page' => 10,
       "orderby"        => "date",
         "order"          => "DESC"
   )); 

?>

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



  // insert values into variables


  <?php endwhile; ?>
  <?php wp_reset_postdata(); ?>


<?php endif; ?>

Thanks in advance, i appreciate any help you can provide.

Read more here: WordPress print latest posts


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: