Best practices
Model your data in the right place
The most expensive mistakes are not in code. They are in where the data lives.
| Your information is… | Put it in… | Why |
|---|---|---|
| About one page only (a hero headline) | A field group on that page type | It lives and dies with the page |
| About the whole site (phone, logo, footer) | An options page | One place, used everywhere |
| A list of the same thing, each with its own page (recipes, events, team) | A content type | It gets its own URL, list, search and permissions |
| A list of the same thing, with no page of its own (slides, FAQs, prices) | A repeater | Rows, in order, inside one post |
| A way to sort content (cuisine, city, level) | A taxonomy | It gives archive pages and filters for free |
| A fixed choice the editor picks (size: S, M, L) | A select or radio | One of a known list |
| A pointer to other content | A post object or relationship Pro | It follows the post if it moves |
| A page built from different pieces | Flexible content Pro, or blocks | The editor chooses the order |
Three questions that decide most cases:
- Does it need its own page? Yes → content type. No → repeater.
- Will you filter or list by it? Yes → taxonomy, or a field you can search with
ugly_find(). - Does one change need to appear in many places? Yes → options page, or a relation. Never copy the same value into five posts.
Return the lightest thing that works
| Field | Return | Then |
|---|---|---|
| Image, file | The ID (the default for images) | wp_get_attachment_image( $id, 'large' ) |
| Select, radio | The value | Compare it in code. Get the label only to print |
| Post object | The ID | Fetch the post only if you need it |
| Date | The format chosen in the field | Reformat in code with wp_date() |
Did this article answer your question?
Thank you. It helps us make the documentation better. Need more help?