WordPress posts under content

How should look my code in order to display a preview of a categories with main main page?
Now its is

<?php $posts = get_posts ("category=2&orderby=date&numberposts=3"); ?> 
 <?php if ($posts) : ?>
 <?php foreach ($posts as $post) : setup_postdata ($post); ?>
 <div>
 <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> 
 </div>
 <?php endforeach; ?>
 <?php endif; ?>

and below this

Read More
<?php if(have_posts()): ?>
<?php while(have_posts()): the_post(); ?>
    <div class="pageContainer"><?php the_content(); ?></div>   
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?><div>Sorry, posts are not found.</div>
<?php endif; ?>

This leads to ignore second part…

Sorry for my english.

Related posts

Leave a Reply

1 comment

  1.  <?php 
           // Category posts
           $posts = get_posts("category=2&orderby=date&numberposts=3");
           if ($posts){
              foreach ($posts as $article){
                 echo '<div><a href="'.get_permalink($article->ID) ?>" rel="bookmark">'.
                       $article->post_title.'</a></div>';
               }
           }
    
           // Current page content
           if ( have_posts() ) :
             while ( have_posts() ) : the_post(); ?>
               <div class="pageContainer">
                   <?php the_content(); ?>
               </div>   
            <?php endwhile;
           else:
               echo '<div>Sorry, posts are not found.</div>';
           endif; 
           ?>