Week Thirteen (MGDP2060)

From Wiki @ Karl Jones dot com
Revision as of 13:14, 3 December 2015 by Karl Jones (Talk | contribs) (WordPress: the loop)

Jump to: navigation, search

This article lists topics for Week Thirteen of Web Design and Development III (MGDP2060).

Previous class session

Next class sessions

  • Week Fourteen - lecture and lab time, but no exercise, no requirements
  • Week Fifteen - guest lecture(s), and (entirely optional) student presentations

WordPress: the loop

WordPress has a concept known as the the loop.

It is so named because it "loops around and around" some data.

Recordset and records

Typically the loop is processing a recordset, which consists of zero or more records.

A record is a unit of data, for example a blog post.

A record typically has multiple data fields. For example, a blog post record typically has fields for Title, Date Posted, Author, Content, etc.

Looping through a recordset

Use the loop to process a recordset, one record at a time.

1. Start at top of loop 2. Display any HTML, and run any PHP code, inside the loop. 2.1 Data in the loop pertains to one recordset at a time, in sequence: first record, second record, etc. 3. At the bottom of the loop, "loop back" to (1) until all records are processed.

You must stop the loop at some point. If you don't stop the loop, you have an "endless loop", which is a Bad Thing.

Stopping the loop

Stopping the loop involves boolean logic (true or false).

The logic can take several different forms. A typical example tests for data at the top of the loop:

  • Is there a record to process?
    • If true, continue with HTML and PHP inside the loop
    • False, jump to the next line of code after the loop

Links to online resources

WordPress custom theme examples

See WordPress custom theme examples.

Next week

Next week -- Week Fourteen -- is the second-to-last class session.

we will discuss domain names, domain name registration, managing domain names, and related topics.

See Week Fourteen.

See also