# A restaurant menu

> Dishes by course, with price, photo and allergens, from a content type.

Source: https://uglydev.com/recipes/a-restaurant-menu/
Updated: 20 November 2026

**What you build.** A menu with dishes, sorted by course (Starters, Mains, Desserts), each with a price, a photo, allergens and a vegan badge. Editors add dishes like posts. The page of the menu prints them by course.

**What you use.** A content type, a taxonomy, one field group, `ugly_find()`.

## Step 1. The content type

1. **UglyFields → Content types → New content type**.
2. Choose **A list of things**.
3. Change the example: singular `Dish`, plural `Dishes`, key `dish`.
4. In **Parts of the editing screen**, keep **Title** and **Featured image**, and turn off **Content editor**. The fields will be all there is.
5. In **Addresses on the site**, set **Start of the address** to `menu`.
6. **Create**.

![The New content type form filled in for Dish](https://uglydev.com/wp-content/uploads/2026/11/shot-a-restaurant-menu-1-scaled.webp)

*The New content type form filled in for Dish.*

## Step 2. The taxonomy

1. Open the **Taxonomies** tab, then **New taxonomy**.
2. Choose **Categories**.
3. Singular `Course`, plural `Courses`, key `course`. Under **Content types**, tick **Dish**.
4. **Create**.

Make three courses from the new **Courses** screen of the Dishes menu: Starters, Mains, Desserts.

## Step 3. The fields

1. **UglyFields → Field groups → New group**. Name it `Dish details`.
2. Add:
  - **Number** `Price`, with **Smallest number** `0`, **Step** `0.5` and **Text before the box** `€`.
  - **Checkboxes** `Allergens`, with choices typed one per line: `gluten`, `dairy`, `nuts`, `eggs`.
  - **Yes / No** `Vegan`.
  - **Text area** `Description`.
3. **Location** → **Post type is Dish**.
4. **Create group**.

![The builder with the fields of Dish details](https://uglydev.com/wp-content/uploads/2026/11/shot-a-restaurant-menu-2-scaled.webp)

*The builder with the fields of Dish details.*

Now add a dish: **Dishes → Add new**. The fields are there.

## Step 4. The template of one dish

`single-dish.php`:

```php
<?php get_header(); ?>

<?php while ( have_posts() ) : the_post(); ?>
	<article class="dish">
		<?php the_post_thumbnail( 'large' ); ?>

		<h1><?php the_title(); ?></h1>

		<p class="dish__price">€ <?php ugly_show( 'price' ); ?></p>

		<?php if ( ugly_get( 'vegan' ) ) : ?>
			<span class="badge">Vegan</span>
		<?php endif; ?>

		<?php if ( ugly_get( 'description' ) ) : ?>
			<p><?php ugly_show( 'description' ); ?></p>
		<?php endif; ?>

		<?php $allergens = (array) ugly_get( 'allergens' ); ?>
		<?php if ( $allergens ) : ?>
			<p>Contains: <?php echo esc_html( implode( ', ', $allergens ) ); ?></p>
		<?php endif; ?>
	</article>
<?php endwhile; ?>

<?php get_footer(); ?>
```

## Step 5. The menu page, by course

`page-menu.php`:

```php
<?php get_header(); ?>

<h1>Menu</h1>

<?php
$courses = get_terms( array( 'taxonomy' => 'course', 'hide_empty' => true ) );

foreach ( $courses as $course ) :
	$dishes = new WP_Query(
		array(
			'post_type'      => 'dish',
			'posts_per_page' => -1,
			'orderby'        => 'title',
			'order'          => 'ASC',
			'tax_query'      => array(
				array(
					'taxonomy' => 'course',
					'terms'    => $course->term_id,
				),
			),
		)
	);
	?>
	<section>
		<h2><?php echo esc_html( $course->name ); ?></h2>

		<?php while ( $dishes->have_posts() ) : $dishes->the_post(); ?>
			<article>
				<h3><?php the_title(); ?> <span>€ <?php ugly_show( 'price' ); ?></span></h3>
			</article>
		<?php endwhile; wp_reset_postdata(); ?>
	</section>
<?php endforeach; ?>

<?php get_footer(); ?>
```

> **Tip:** a normal `WP_Query` is the right tool to filter by a taxonomy. `ugly_find()` is for filtering by the **values of fields**, as the next step shows.

## Step 6. Only the vegan dishes

```php
$vegan = ugly_find( 'dish', array( 'vegan' => true ), array( 'order' => 'price asc' ) );
```

## What you learned

- A content type, a taxonomy and a group are three separate things that work together by **location**.
- `ugly_find()` gives you a `WP_Query` and takes conditions on **fields** as an array. For a taxonomy, use a normal `WP_Query`.
- Everything you made is in `ugly-json/`, ready to commit.
