How to display post in wordpress custom theme

One of the default WordPress functionalities is to show your latest posts on your homepage. However, users often want to differentiate between their homepage and the page that contains the posts. This can be easily set as it is one of the default WordPress options, located in the Settings section.

index.php

<header>

<?php
   get_header();
?>

</header>

<div class="card">

<?php

  if ( have_posts() ) : while( have_posts()  ) : the_post(); ?>

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

    <a href="<?php the_permalink(); ?>">
        <?php the_post_thumbnail( 'full' ); ?>
    </a>

  <p><?php the_excerpt(); ?></p>

<?php endwhile; endif; 

?>

<?php echo previous_post_link(); ?> 
<?php echo next_post_link(); ?>
</div>

<footer>

<?php
   get_footer();
?>

</footer>
get custom post type

<?php

$query = ['post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 3, 'order' => 'DESC', 'offset' => 1];
$movieQuery = new Wp_Query($query);
$i = 0;

while($movieQuery->have_posts()){
$movieQuery->the_post();

$thumbPath = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
if($thumbPath){
$thumb = $thumbPath[0];
}
else{
$thumb = '';
}

?>
single.php

<?php if ( have_posts() ) : while( have_posts()  ) : the_post(); ?>
    <h1><?php the_title(); ?></h1>
    <a href="<?php the_permalink(); ?>">
        <?php the_post_thumbnail( 'full' ); ?>
    </a>
    <p><?php the_excerpt(); ?></p>
<?php endwhile; endif; ?>

Leave a Reply