Help topics

Shortcode and block reference

Morphic provides three shortcodes and a block binding source. Add a shortcode to the content of any WordPress page or post, and use the block binding source in the block editor.

[morphic_list]

Shows the entries of one model as a list, table or cards.

Example: [morphic_list model="book" layout="table" fields="author,price" limit="5"]

AttributeWhat it doesOptionsDefault
modelThe model whose entries are listed. Nothing is shown when this is empty or the model is not registered.Model name(empty)
whereFilters the entries. Separate conditions with commas. Use field:value for an exact match, and >, >=, < or <= for a range. Only one range field is allowed.field:value, field>=value, field<value and the other range forms(empty, no filter)
orderThe field to sort by. Put a minus sign before the field name to sort in descending order.Field name, or - + field name(empty)
limitThe number of entries. A value below 1 is shown as 1, and a value above 100 as 100.1 to 10010
layoutHow the entries are shown. Any other value shows cards.cards, list, tablecards
fieldsThe fields to show, in the order given, separated by commas. The list layout ignores this attribute.Field names(empty)
langThe language of the entries. When empty, no language is passed to the query.Language code(empty)
  • With no where, and order empty or -created, the entries come back in reverse order.
  • Cards show the first three fields of the model when fields is empty. The title field is not repeated, so fewer than three may show. The table shows all fields.

[morphic_entry]

Shows one entry. Without content between the tags, it shows the entry title as a heading and the other fields with their labels.

Example: [morphic_entry model="book" unique="title" slug="Maps of Forgotten Towns" fields="author,price"]

AttributeWhat it doesOptionsDefault
modelThe model of the entry. Nothing is shown when this is empty or the model is not registered.Model name(empty)
idThe ID of the entry. When this is set, unique and slug are ignored.Entry ID(empty)
slugThe value to match in the field named by unique. Used only when id is empty.Value(empty)
uniqueThe field that slug is matched against.Field nameslug
fieldsThe fields to show, in the order given, separated by commas. When empty, all fields are shown except the title field.Field names(empty)
langThe language of the entry. Used only together with id.Language code(empty)
  • Content between [morphic_entry] and [/morphic_entry] is shown with the entry as context, so [morphic_field] inside it shows values of this entry. The content is filtered with the same rules as WordPress post content, plus iframe tags.

[morphic_field]

Shows one value of an entry.

Example: [morphic_field name="author"]

AttributeWhat it doesOptionsDefault
nameThe field to show. title shows the entry title, and url shows the public URL of the entry. Names that are not fields of the model show nothing.Field name, title, url(empty)
idThe entry to use when there is no entry in context and no current Morphic page.Entry ID(empty)
modelThe model of id. Used only together with id.Model name(empty)
  • The entry in context is the entry of the nearest enclosing [morphic_entry]. When there is none, the current Morphic page is used.
  • [morphic_field] shows nothing when there is no entry.

Values shown by the shortcodes and block bindings

  • A Yes or No field shows Yes or No.
  • Secret and hidden fields never show, in any shortcode or block binding. Empty values show nothing.

Block bindings

  • Morphic field is the name of the block binding source (morphic/field) in the block editor. Set the binding argument key to a field name. The source shows nothing when the post has no entry, the key is empty, or the model has no field with that name.
  • Post Author Name (core/post-author-name) with no text of its own shows the names in the entry's byline, up to three, separated by commas. The byline is the relation field configured as byline. When none is configured, Morphic uses the first relation field named author, authors, writer, byline or createdBy.
  • Post Terms (core/post-terms) with no text of its own shows the linked entries for the taxonomy in its term setting. Only category and post_tag are supported. The separator is , unless the block sets separator.

Labels and fallbacks

TextWhere it appears
UntitledThe title of an entry that has no title value.
TitleThe first column heading of a table when the model has no title field.
Morphic fieldThe name of the block binding source.
Yes and NoThe values of Yes or No fields.
Nothing here yet.A list with no entries.

[morphic_field name="url"] shows nothing when the entry has no URL. No label is shown in that case.

Errors and visitor output

  • A list with a where or order that no index answers shows this text to users with the manage_options capability. Other visitors see nothing: No filter of book matches this list. Turn on "Filter by this field" for: author. The model name comes from model, and the field names come from where.
  • A lookup error in any shortcode shows its message to users with the manage_options capability, in a paragraph with the class morphic-error. Other visitors see no output. See Error codes and messages reference for the messages.

Secret and hidden fields

Secret and hidden fields never show in a shortcode or a block binding. In a table, the column heading still shows and the cell stays empty.