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 WordPress Theme file

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 | Category: Single Post


Leave a Reply

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

Advertising

Related posts

How to quickly install Roots Trellis and Bedrock for local development environment on Windows

Trellis is a LEMP stack for WordPress local development environment. In this short tutorial I will walk you through the installation itself but be …

What do you need to install on your Windows PC for work with Roots Trellis and Bedrock stack.

I have compiled a list of programs that you need to install on your Windows PC in order to run Roots Trellis and …