Common Arguments
Last updated
Was this helpful?
Last updated
Was this helpful?
Shortcodes is the native WordPress feature that allows you to call PHP functions in various places, e.g. inside the Gutenberg editor.
Views and Cards have their own shortcodes. See the examples below.
Using extra arguments, you can further configure the behaviour of View or Card instances. You can find the View shortcode arguments on and the Card shortcode arguments . However, both shortcodes share a common argument that allows you to restrict content visibility. See the information below.
WordPress shortcodes can be added as plain text in almost any location. WordPress automatically parses them during rendering, calls the related PHP functions, and replaces the shortcode with the generated output. You can paste the shortcode, such as [avf_view name="Name of View" view-id="651d5d75bfdf2"]
, in places like Gutenberg or the Classic Editor, sidebars, and other locations.
If you need to use a shortcode within PHP code, such as in your theme templates, there are two methods to achieve this:
do_shortcode
functionis a built-in WordPress function that renders shortcodes within PHP code. You can use it like this:
The Advanced Views Framework offers a dedicated class for rendering Views and Cards. This class employs the same argument names and values as the standard shortcode but converts them into methods.
Consequently, when you're editing PHP files in your IDE, you can leverage autocomplete suggestions to access the list of available arguments without the need to consult the documentation.
The methods require two arguments: a unique ID and a name. The name is used for clarification purposes only, so it doesn't need to be identical to the current View or Card name.
If you need to set up extra arguments, you can call the related methods before the render call. For example, let's consider the example with the user-with-roles
argument described below on this page:
This argument allows you to add class to your View or Card main wrapper dynamically.
In most cases, you should add all the classes directly to your View or Card, but in some cases you will need to assign this class dynamically. For example, inside your Card, you may want to add some specific class to your View, that specific to this Card only.
Both "user-with-roles" and "user-without-roles" arguments allow you restricting access to the specific View or Card.
Custom arguments are available only inside your Custom Data snippet. They're not available directly in View or Card template. If you need to pass to use them inside the template, you can transit them in the snippet.
In addition, unlike do_shortcode
, you can pass variables with any type, including objects and arrays to the and Custom Data snippet features.
When you use or Custom Data feature, you can pass any custom arguments to your snippet using this argument.
Pro tip: In Card, you can also access these arguments in the and using the magic prefix: $custom-arguments$.my-field
.