Custom Loop Example With WordPress/Oxygen/Metabox

This is a short example of a custom loop in WordPress. The purpose of this code was to generate a filterable list of QuietCool whole house fan models for an electrician's website. Setting them up as a custom post type also enables a non-developer to easily add or edit models, details, and pricing from wp-admin. I used the Metabox Builder plugin to easily set up the custom fields. The rwmb_meta function you see in the PHP attached is a Metabox helper function to get the custom field values.

The end result with styling dependent on the category.

I'm using Metabox to create the custom post type and metabox fields.

The styling is handled with Oxygen's selector detector.

Probably the most interesting part of this project was styling the loop output blocks depending on what model category they belonged to. This was accomplished with PHP by adding classes to the div depending on the value of a custom field called "category". For example: <div class = " some-class php if statement echo color class here"> This sets the style "some-class" on every iteration of this div and assigns a "color" class also depending on the result of the if statement.