How to create simple WordPress Loop for posts and display it in single.php WordPress Theme file

How To Create Simple Wordpress Loop For Posts And Display It In Single.php

Here is a simple snippet for single.php Loop

With the code below you can display you single post/page content and get header.php and footer.php

1. The WordPress Loop starts with

Then our WordPress Loop should continue with both most important part of every page

  • the_title
  • the_content

2. Add this code to display your page/post title inside your WordPress Page/post Loop

3. Display the Content of your WordPress page/post

4. End your WordPress Loop

5. Support any additional content markups in your loop

You can always echo any additional content like share buttons and any meta data from your single post or page like

  • the_date
  • tags
  • categories
  • breadcrumb

6. View the full WordPress Loop code below

Please: Note

If you want this code to work for you your single.php or page.php file should use both default WordPress functions to get header and footer content like below

So the actual WordPress Loop for you single.php or page.php should look like this

Don’t forget to wrap it in HTML and style it with CSS


Autor: wpsnipp | Modified: March 1, 2019 at 8:02 am

Leave a Reply

Your email address will not be published. Required fields are marked *


Related posts

What does the_content and get_the_content do in WordPress?

What does the_content and get_the_content do in WordPress?

The WordPress functions the_content and get_the_content are used to pull the main text area from the page or post. The difference between them …

Change The Color Of Wordpress Admin Dashboard Icon In The Menu

How to change Dash icon color in WordPress admin menu with CSS?

Change the default color for dash icon in the admin menu Probably you have this question when you create a Custom WordPress Theme …