# Plugin Shortcodes

DinOdds lets you display betting odds tables anywhere on your site using a simple `[odds]` shortcode. You can generate these shortcodes from the admin interface and paste them into posts, pages, or widgets. In the block editor you can use the [Odds Table block](https://docs.affkraft.com/dinodds/blocks) instead; both show the same table.

## Shortcode Overview

The base shortcode format is:

```text
[odds league="" bookies="" style="" layout="" class="" type="" selector="" away="" home=""]
```

You must choose a **league**; without one nothing is shown. All other attributes are optional. `💁 since version 1.7` any attribute you leave out falls back to the site-wide defaults from the [Display tab](https://docs.affkraft.com/dinodds/colors) (style, layout, type and selector), and to all sportsbooks when `bookies` is empty.

## Shortcode Types

`💁 since version 1.3` there are two main ways to display odds:

* **All League Odds**
  Display an odds table for all *upcoming* matches in a given league.

* **Single Match Odds**
  Display odds for a single match in that league by specifying both `away` and `home` team names.

If **both** `away` and `home` are provided, DinOdds will attempt to find and display that single upcoming match. If either is missing, DinOdds falls back to the **All League Odds** view. Matches that have already started are not shown.

### Shortcode Styles

`💁 since version 1.5` there are two styles you can use for displaying odds:

* **Style 1**: Navigate left and right using arrows
* **Style 2**: Navigate left and right using the mouse and/or keyboard

Style 2 has no layout option (`layout` is ignored), and no separate single-match view: a single match with Style 2 is shown as a one-row table.

### Examples

* All league odds (default style and layout):

  ```text
  [odds league="nfl"]
  ```

* All league odds with selected bookies, style 2, without odds type selector:

  ```text
  [odds league="nfl" bookies="mybookie,betonline" style="2" selector="false"]
  ```

* Single match odds for a specific game:

  ```text
  [odds league="nfl" away="Buffalo Bills" home="Houston Texans"]
  ```

## Shortcode Generator

You don't need to write attributes by hand. Open the **Shortcode** tab in the DinOdds settings:

1. **League**: choose a league from the dropdown. Required.
2. **Match**: leave on **All matches**, or pick one upcoming game. The list loads when you choose a league and fills in `away` and `home` for you.
3. **Sportsbooks**: tick the sportsbooks to show. Leave all unticked to show every sportsbook.
4. **Style**: **Default** (your Display tab value), **Style 1** or **Style 2**.
5. **Links layout**: **Default**, **Top** or **Inline**. Hidden when Style 2 is chosen.
6. **Odds type**: **Default**, **Spread**, **Moneyline** or **Total**.
7. **Type selector**: **Default**, **Show** or **Hide**.
8. **CSS class**: an optional extra class you can target in your theme styles.

The shortcode and a live preview of the table update as you change the options. Settings left on **Default** are not added to the shortcode, so the table follows the Display tab. Click **Copy shortcode** and paste it wherever you want the table to appear.

## Shortcode Attributes

| Attribute  | Required | Description                                                                                                  | Default                           |
| ---------- | -------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------- |
| `league`   | Yes      | League identifier whose odds you want to display, e.g. `nfl`.                                                | —                                 |
| `bookies`  | No       | Comma-separated list of sportsbook slugs, e.g. `mybookie,betonline`. Only sportsbooks in your feed are used; names are not case-sensitive. | All sportsbooks, in saved order   |
| `style`    | No       | Table style: `1` or `2`.                                                                                     | Display tab (`1`)                 |
| `layout`   | No       | Where sportsbook links appear: `top` or `inline`. Ignored by style 2.                                        | Display tab (`top`)               |
| `type`     | No       | Odds type shown first: `spread`, `moneyline` or `total`.                                                     | Display tab (`spread`)            |
| `selector` | No       | Whether to display the odds type selector: `true` or `false`.                                                | Display tab (`true`)              |
| `class`    | No       | Extra CSS class added to the table as `df-odds--{class}`.                                                    | —                                 |
| `away`     | No       | Away team name for a single match. Needs `home` too.                                                         | —                                 |
| `home`     | No       | Home team name for a single match. Needs `away` too.                                                         | —                                 |

Team names must match the names in the feed exactly; use the generator's **Match** list to get them right. A value that isn't allowed (for example `style="3"`) is ignored and the Display tab value is used.

When there are **no upcoming matches** for the chosen league (or no matching single game for the given teams), DinOdds displays a "no matches available" view instead of leaving the page blank.

## How the odds are loaded

The shortcode outputs only an empty table with a loading animation. The visitor's browser then loads the odds from the [REST endpoint](https://docs.affkraft.com/dinodds/rest-api). Because no odds are saved in the page itself, page caches can't serve stale odds. Visitors need JavaScript enabled to see the odds.
