For the complete documentation index, see llms.txt. This page is also available as Markdown.

Layout embedding shortcode

In Advanced Views, Layout embedding happens using native WordPress shortcodes. Each Layout has its own unique shortcode that can be pasted into any location, regardless of the theme, editor, or page builder you're using.

Shortcodes also support arguments, allowing you to customize the behavior of the same entity in different contexts.

1. Shortcode format

Each Layout shortcode should contain at least 2 arguments:

[avf-layout name="Name" id="651d5d75bfdf2"]
  1. name argument - used for clarification purposes only and doesn't play any functional role.

  2. id argument - associates the shortcode with a specific Layout.

By default, the shortcode uses the current object (Post, Page, Product, or any Custom Post Type) where it is placed as the fields source. To use a different object as the fields source, define the object-id argument described below:

2. "object-id" argument

Using object-id shortcode argument, you can change the Layout fields source and display fields from any WordPress object. Below is the overview:

Fields source
"object-id" argument

(omitted)

specific Post, resolved by the ID

object-id="NUMERIC_ID"

specific Post, resolved by the slug

object-id="post" post-slug="SLUG"

object-id="options"

current User (logged-in user viewing the page, not the static user who created the Layout)

object-id="user"

object-id="user" user-id="NUMERIC_ID"

current Taxonomy term (only if you paste the shortcode on the term template/page)

object-id="term"

object-id="term" term-id="NUMERIC_ID"

object-id="comment" comment-id="NUMERIC_ID"

object-id="menu" menu-slug="SLUG"

object-id="NUMERIC_ID" (the same as Post)

This table refers to "Post" as a generic WordPress term that covers Post, Page, any Custom Post Type, Media attachment, Woo Product, and other entities. With Advanced Views, you can display fields from any entity.

3. Common arguments

The following shortcode arguments can be added to any Layout shortcode:

3.1) class - adding HTML class

This argument allows you to add a class to your Layout main wrapper dynamically.

In most cases, you should add all the classes directly to your Layout, but in some cases you will need to assign this class dynamically. For example, inside your Post Selection, you may want to add a specific class to your Layout that is specific to this Post Selection only.

3.2) user-with-role - restricting visibility by role

Both "user-with-roles" and "user-without-roles" arguments allow you to restrict access to the specific Layout.

"Restrict" means that the shortcode won't be rendered, so if you'd like to show a restriction type message to users, then consider customizing the Layout template to check user roles there.

3.3) custom-arguments - transiting fields

Using this argument, you can pass any custom arguments to the Layout Controller:

4. Displaying inside theme templates

To embed Layout into theme templates, you can either render the text shortcode using a native WordPress do_shortcode function, or employ the Advanced Views API:

Last updated