Wordpress - Displaying content of single post

  1. Create a file named single.php. This will automatically get all you single posts. For more information about WordPress' template hierarchy, read the Codex

  2. Inside single.php, run the default loop and get header.php, sidebar.php and footer.php

    <?php get_header(); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
     <?php the_title(); ?>
     <?php the_content(); ?>
     <?php echo get_the_date(); ?>
    
    <?php endwhile; ?>
    <?php endif; ?>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    

you can use below function to get content of Wordpress post

     <?php echo get_the_content(); ?>

and you can use below function to get title

    <?php echo get_the_title(); ?>

to get date you can use this function

    <?php echo echo get_the_date(); ?>

Tags:

Posts