Layout Shortcode

circle-info

This page contains Layout specific shortcode arguments. You can read about general arguments, that are the same for Layouts and Post Selections herearrow-up-right.

Default shortcode

Classic shortcodearrow-up-right:

[avf-layout name="Name of Layout" id="651d5d75bfdf2"]
circle-info

Note: Displays the Layout, chosen meta fields should be filled at the same object where the shortcode is pasted (post/page), replace id="651d5d75bfdf2" with the ID of your Layout.

In PHP codearrow-up-right:

<?php

// a) using do_shortcode
echo do_shortcode('[avf-layout name="Name of Layout" id="651d5d75bfdf2"]');

// b) using the special plugin class
use Org\Wplake\Advanced_Views\Bridge\Advanced_Views;

echo Advanced_Views::view_shortcode('651d5d75bfdf2', 'name')
    ->render();

By default, Layout shortcodes contain two arguments: "name" and "id". The "name" is used for clarification purposes only and doesn't play any functional role. The "id" argument is the most important as it allows Advanced Views to associate the shortcode with a specific Layout.

Arguments

Besides the common shortcode argumentsarrow-up-right, the Layout shortcode has the following arguments:

object-id

This argument allows to define a source, from which the Layout fields will be loaded. By default, the object-id argument is skipped, and Advanced Views automatically picks up the ID of the currently displayed object (current post/page/taxonomy). If you need to change the default behavior, see the details below.

1. Loading fields from a specific post/CPT item

Classic shortcodearrow-up-right:

In PHP codearrow-up-right:

Loading by ID is the default approach. However, loading by slug is preferred if you have multiple environments (e.g., Localhost and Live) where IDs may differ, especially if synchronization is not performed regularly.

2. Loading fields from an Options page

circle-info

If you made your option page using the Advanced Custom Fields options featurearrow-up-right, you should use the "options" keyword for ANY options page.

If you made your option page using the MB Settings page featurearrow-up-right, you should use the ID of your options page in the argument.

Classic shortcodearrow-up-right:

In PHP codearrow-up-right:

3. Loading fields from a User profile

Classic shortcodearrow-up-right:

circle-info

The second argument, user-id is optional. If you skip it, Advanced Views will automatically get the id of the current user during rendering and load fields from it.

Note: "current user" doesn't mean the user who made the Layout, or pasted the shortcode, but the specific user, who is viewing the page.

In PHP codearrow-up-right:

4. Loading fields from a taxonomy term

Classic shortcodearrow-up-right:

circle-info

If you paste the shortcode on the term template/page, the second argument can be omitted.

In PHP code:

5. Loading fields from a comment

Classic shortcodearrow-up-right:

In PHP codearrow-up-right:

6. Loading fields from a menu

Classic shortcodearrow-up-right:

In PHP codearrow-up-right:

7. Loading fields from a menu item

In WordPress, every menu item is a Post. So you can load a Layout from the Menu item by passing its ID into the object-id argument, like in the first "Loading fields from a specific post/CPT item" case.

FAQs

chevron-rightShortcode shows (internal use only)hashtag

In Advanced Views Pro, use "Parent Group" if you plan to select Fields from the same Field Group. If you make use of the "Parent Group" and "Parent field" then the shortcode will show (internal use only) and can't be used directly on posts or pages to display fields. That's because its reserved for Internal Layouts that are used for the nested setup of the group, repeater or flexible field types. See the Nested Repeater guide here.

Last updated