Loops and reusable item layouts
Repeat a card layout over a WordPress query, including empty states, alternate items, and pagination.
Watch the video
Chapters and transcript Captions are included.
Build one item, then repeat it#
A loop combines a query with an item layout. Its wrapper uses data-ke-loop; the normal item is .ke-loop-item. Put dynamic title, image, excerpt, and link bindings in that item so each result displays its own values.
A loop can use its own query or an existing query context. Public queries exclude unpublished and password-protected content. Choose the post type, ordering, and filters intentionally; a visually correct card with the wrong query still shows the wrong content.
Empty and alternate states#
A .ke-loop-empty element supplies the no-results state. An optional .ke-loop-alt with data-ke-every supplies a periodic alternate layout. Test zero results, one result, several results, and enough results to paginate.
Pagination uses a loop-specific kl- query parameter. Filter state uses kf- and kfo- parameters. Keep stable loop identities when linking to filtered results.
Saved loop templates#
A kindly_loop record stores a reusable single-card layout. data-ke-loop-tpl links a loop to the published template, while retaining a saved fallback. If the template is missing, the saved copy remains available. The published template is resolved before dynamic data fills it.
Since 0.9.17, Kindly Edit > Loops in WordPress lists loop templates in one table: a small drawing, the name, Used on (the pages whose loops use it) and its status. Add loop template in the Loop templates header (or Add a loop template under an empty list, 0.9.19 and later) opens a focused window: type a name, then Create and edit; Esc, Close or Cancel leave without making anything. Move to the Trash asks first, and trashing a loop template leaves every loop that used it showing its last copy. The Trash section at the end restores one as a draft. On phones, each row stacks with its column names beside the values. Since 0.9.21, the video button beside the Loops title plays the Loops video in a window over the screen.
Loop templates require one root element. Alternate-item metadata is removed from a saved single-card template. Executable JavaScript and PHP are not carried in this library; CSS remains permission-gated. Template management requires theme-editing capability.
Verify a loop#
Open links from several rendered cards and confirm each points to its own post. Check image alternatives and headings. Test pagination alongside another loop to confirm independent state. Inspect the empty message with a query that has no matches, then return to the intended query before publishing.