Skip to main content

Automating the puzzle embed process

Objective

Learn how to automate the process of publishing individual puzzles, using parameters that can predictably identify a puzzle.

When you are managing a lot of puzzles, you will need ways to address and load your puzzles in predictable ways. You can set up embed codes for a specific puzzle using one of three ways: (a) by its slug, which can be assigned at the time of puzzle creation or import (b) by publication date, or (c) by position in the series (i.e., the most recent puzzle, etc.) You should use exactly one of those methods, so do not specify more than one of these parameters. Read on to find out more about each option.

Predictable slugs for date based puzzles

In this method, the puzzle slug is explicitly set by you. This slug can be set at the time of puzzle creation or import and cannot be changed once it has been set.

There are two ways to set the slug. The first is to enter it manually in the slug field while creating the puzzle. The second way is a shortcut provided by the PuzzleMe™ platform upon import of files named in a certain format. Such files automatically lead to a slug and publish time being set according to the filename when the puzzle is imported. The filename should be made up of two parts - a prefix and the publish date for the puzzle, which is represented in YYYYMMDD format, separated by the "" (underscore) character. For example, an imported puzzle file intended to be published on 29th July, 2025 could be named _sample-crossword_20250729.xml. PuzzleMe will automatically set the puzzle's publish time to midnight (00:00) of 29th July, 2025, and set the slug to sample-crossword_20250729 . This slug can then be used to refer to and embed this puzzle. Note that the part of the filename before the underscores can only have the letters A-Z (or a-z), digits and hyphens. Spaces and other special characters are not allowed.

This method will lead to a puzzle URL that looks like this:

https://cdnx.amuselabs.com/pmm/crossword?set=sample-crossword&id=slug-that-you-set
https://cdnx.amuselabs.com/pmm/crossword?set=sample-crossword&id=sample-crossword_20250729

This approach can also be used to predictably generate the PuzzleMe WordPress plugin shortcode. In the sample shortcode below, the value of the id is generated based on the formula described above.

[puzzleme basepath='https://puzzleme.amuselabs.com/pmm/' set='sample-crossword' id='sample-crossword_20220709' type='crossword']
Tip

This approach works best when puzzles are published with a regular cadence and you need control over the puzzle's slug in order to get predictable embed codes or shortcodes.

Load puzzle by publication date

You can load a puzzle by providing its publication date in YYYY-MM-dd format.

  1. If you are using a time zone other than UTC, it can be specified through the URL param 'timezone' using the standard IANA format. If no time zone is specified, the default assumed is UTC.
  2. If more than one puzzle in a series falls within the specified time window, the latest one is loaded in the iframe.
  3. If no puzzle is published in the specified time window, an error page is returned, indicating that no puzzle is available.

For example, if you would like to load a puzzle published on Feb 6th 2025, you can use the URL parameter: date=2025-02-06. The puzzle that was published between 2025-02-06 12 AM and 2025-02-06 11:59:59 PM in the given time zone will appear in the iframe. An example link will look like this:

https://cdnx.amuselabs.com/pmm/crossword?date=2025-02-06&set=sample-crossword&timezone=timezone=America/New_York
Tip

Use this method when you have a regular puzzle publication schedule and would like to set up a container page (or a page template) that embeds a puzzle for a given date. You can also use this method to distribute direct links to puzzles.

Index based puzzle ID

note

This approach can be used to load a specific puzzle directly based on its recency in a series. Note that the embed has to be routed via the date picker. This also means that solvers will always have the option to go back to the picker from the puzzle.

In this approach, a specific puzzle is referred to using its position in reverse chronological order of all the puzzles present in the given series. The most recently published puzzle in a series is denoted by index 1, the puzzle published before it is denoted by index 2, and so on. For example, if a series contains exactly 4 puzzles - A,B C and D, and their publish dates are set to the 10th, 11th, 12th and 13th of the month respectively, then the puzzles will be referred to using the index 4, 3, 2 and 1 respectively.

The index is specified using the idx parameter. When a puzzle is loaded using this parameter, the puzzle slug does not need to be specified. For example, the iframe URL for the first puzzle in the sample-crossword series would become:

https://cdnx.amuselabs.com/pmm/date-picker?idx=1&set=sample-crossword&embed=1

The index of a puzzle can change if puzzles are added to or deleted from the series, or have their publish date and time modified. For example, If a new/existing puzzle’s publish date/time is set after a specific given puzzle, then the index of the given puzzle would increase by 1.

This approach can also be used with the WordPress plugin. See the example shortcode below.

[puzzleme basepath='https://puzzleme.amuselabs.com/pmm/' set='sample-crossword' type='date-picker' embedparams='idx=1']
Tip

This approach is useful for a page which needs to embed the latest published puzzle in a series without needing to know the puzzle's slug. As new puzzles are published, the PuzzleMe iframe updates automatically without the container page needing to update.