Magic Fields

Settings Dialogue Box

Related help

Magic Fields

Magic Fields

In WordPress, ‘Magic Fields’ are custom fields that can be dynamically replaced with specific values when a page loads. You can select Magic Fields from certain drop-down input field where you see an option surrounded by quotation marks. When your AGB grid runs, it replaces the magic fields with corresponding values that are relative to the post that is currently loading. This is particularly useful when adding your AGB grid to an archive page, which is a special type of page that aggregates certain types of content, like posts from a specific category or date range. The values for the magic field would vary depending on the specific content being loaded on the archive page.

Fields

%post_slug%

Magic Fields

The term ‘slug’ in WordPress refers to a URL-friendly version of a post or page title. It’s used in the web address of the post or page and is often based on the title of the post or page. This field will return the slug of the currently loading post or page.

A use case for this magic field is you want to build a photo gallery with Advanced Grid Builder using images that are related to the current page. Using the Media Library, a built-in WordPress tool for managing media files, you can add a category to those images you want included that has the same category term slug as the page slug on which it should appear.

 

%attached_terms%

Magic Fields

The %attached_terms% feature in AGB offers a dynamic way to filter and display content in a grid based on the terms attached to the current page. It operates within the context of WordPress taxonomies, enabling highly flexible and context-sensitive content presentation.

  1. Dynamic Term Matching: This feature allows the grid to display only posts with terms matching those attached to the current page, creating a dynamic link between the page and the grid content.
  2. Taxonomy Filter Configuration: Specify a taxonomy in the ‘Taxonomy Filter’ field of the grid settings. The feature uses this taxonomy to match terms between the grid and the current page.
  3. Independent Post Types: The grid can display different post types, not necessarily the same as the current page’s post type. The key factor is the shared taxonomy.
  4. Shared Taxonomy Requirement: Both the grid and the page need to share the same taxonomy for the feature to work effectively.
  5. Practical Example: On a page about ‘Landscape Photography’ with the term ‘Landscape’ attached, a grid with the %attached_terms% feature will show posts marked with ‘Landscape’ in the same taxonomy.
  6. Versatile Applications: Ideal for portfolio sites, e-commerce product displays, blog archives, and more, this feature enhances user experience and site organization.