What is The WordPress Loop?

By Monday, June 17, 2013 No tags 0

The Loop is PHP code used by Word­Press to dis­play posts. Us­ing The Loop, Word­Press process­es each post to be dis­played on the cur­rent page, and for­mats it ac­cord­ing to how it match­es spec­i­fied cri­te­ria with­in The Loop tags. Any HTML or PHP code in the Loop will be processed on each post.

When Word­Press doc­u­men­ta­tion says “This tag must be with­in The Loop”, such as for spe­cif­ic Tem­plate Tag or plu­g­ins, the tag will be re­peat­ed for each post. For ex­am­ple, The Loop dis­plays the fol­low­ing in­for­ma­tion by de­fault for each post:

You can dis­play oth­er in­for­ma­tion about each post us­ing the ap­pro­pri­ate Tem­plate Tags or (for ad­vanced users) by ac­cess­ing the vari­able, which is set with the cur­rent post’s in­for­ma­tion while The Loop is run­ning.

Comments are closed.