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; 

?>

</div>

<footer>

<?php
   get_footer();
?>

</footer>
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