Custom Layout template
Once you've defined the fields list in your Layout, Advanced Views automatically generates a default template for them. It recognizes each field type and produces the appropriate markup - for example, an <img> tag for an Image field, a loop for a Gallery field, and so on.
By copying the Default Template into the Custom Template field, you are getting complete control over the markup.
Advanced Views eliminates the need to learn your field provider's documentation or manually retrieve field data. It automatically transforms raw database values into template-ready formats.
For example, an image ID stored in the database is passed as a complete image object with properties such as src, width, and height.This lets you focus on crafting the layout instead of dealing with field types and meta retrieval.
Layouts are composable, meaning one Layout can include another. Layout templates also support arbitrary logic, allowing you to perform operations such as combining field values, formatting output, or calling any WordPress function directly within the template.
1. How to customize Layout template
Both Default Template and Custom Template fields are smart templates that use one of the built-in template engines.
Go to Edit your Layout.
Switch to the Template tab.
Select the Default Template code and copy it.
Paste the code in the Custom Template field.
Edit the markup as needed.
Click on Update to save your Layout.
If you have added new fields in your Layout, remember to click Update to ensure that you have the latest template before editing.
2. How to display arbitrary fields
If you need to add arbitrary fields from a provider that is not supported by Advanced Views out of the box, you can add the get_post_meta() WordPress call into the template and display any meta value.
For vanilla PHP:
For Blade:
For Twig, you have to load the field via the Layout Controller.
Ensure you replace the field name with yours - you can consult your data vendor's docs. Alternatively, you can use any PHP function that your data vendor provides to fetch values.
Last updated