Query Source

Before diving into the specifics of the query source for the Advanced Grid Builder plugin, it's important to understand some foundational concepts. WordPress is a Content Management System (CMS) that lets you create, manage, and modify content on your website without directly interacting with code. For more information on how WordPress works, you can refer to this WordPress documentation. WordPress organises the data you input—such as posts, pages, and media—in a structured way. This data is stored in a database, making it accessible to different parts of your website for display.

When we talk about a "data source" for a plugin like Advanced Grid Builder, we're referring to the specific part of the database that the plugin should use to find the content it needs to display. It's like telling the plugin which shelf in the library to find the right book. Defining the query source ensures that the plugin displays the correct content in the desired way.

The Role of Taxonomies in WordPress

In WordPress, taxonomies are used to categorise and organise content. Think of taxonomies as a sorting system in a large library. To learn more about taxonomies and their uses in WordPress, see this guide on WordPress taxonomies. Each book in the library (or piece of content on your website) can have various attributes, like author, genre, or publication date. In WordPress, these attributes are called "taxonomies." The two default taxonomies in WordPress are "Categories" and "Tags," but you can also create custom taxonomies tailored to your needs.

For example, if you run a travel blog, you could create a taxonomy called "Destinations." Then, each post could be categorised by destination, making it easier for visitors to find all posts about "Sydney" or "Melbourne." Understanding taxonomies helps you organise your content in a user-friendly way, enhancing your visitors' experience.

Query Source Fields

The Query Source Fields in the Advanced Grid Builder plugin allow you to specify the WordPress data source used to populate your grid. There are four options available:

Post Type

Selecting "Post Type" lets you choose a specific WordPress post type to populate your grid. The dropdown menu includes all registered default and custom post types, making it easy to select the one you need.

Taxonomy

If you select "Taxonomy," you can choose a specific taxonomy from the dropdown menu. This menu includes all default and custom taxonomies registered in your WordPress installation. This option lets you populate your grid with terms from the selected taxonomy.

Media Library

By choosing "Media Library," you can populate your grid with content from the WordPress Media Library. This is a great option if you want to create a grid of images.

Loop

To understand the "Loop" option, it's helpful to know about the WordPress Loop and archive pages. The Loop is a mechanism WordPress uses to display content based on specific criteria. It works like a carousel, cycling through your content and displaying each item on your website. For a deeper understanding of how the WordPress Loop works, visit this detailed explanation.

An "archive page" in WordPress is a collection of content on a particular topic, like a catalogue of books in a library. You can find more details about archive pages in WordPress here. For example, an archive page could display all posts from the "Sydney" category of a travel blog.

The Advanced Grid Builder plugin can work with the Loop and archive pages. When you select "Loop" as your query source, the plugin populates your grid based on the current Loop—whether it's a specific category, date range, author, or other criteria. This is especially useful for archive pages, where grid content can dynamically change based on the specific archive page that's loaded. This flexibility allows you to create dynamic displays of content on your WordPress site.

Selecting "Loop" will populate your grid based on the current query source in the WordPress Loop. This is useful for pages like taxonomy archive pages. The grid content will change dynamically based on the specific archive page.

Filter Fields

Depending on your Query Source selection, additional fields may appear that allow you to filter the query source by taxonomy terms. These fields include:

Taxonomy Filter

Here, you can select a taxonomy or 'IDs' from the dropdown menu. This menu includes all default and custom taxonomies registered in your WordPress installation, as well as an 'IDs' option. To understand more about working with taxonomies and IDs in WordPress, refer to this article on working with custom fields and taxonomies. If you select 'IDs', you can provide the IDs in the 'Filter Term Slug' field, and the posts will be filtered to only include or exclude those with the supplied IDs, based on the filter operator. This feature is included here because it makes the filtering process more powerful and avoids having to create separate filter fields for IDs and taxonomies, even though it may seem inconsistent with the label 'Taxonomy Filter'.

Filter Operator

You can choose "In" or "Not In" as the operator to apply to the supplied terms or IDs. This determines whether the grid includes or excludes content tagged with the specified terms or IDs.

Filter Term Slug

In this field, enter a term slug (not a term name) or IDs. You can provide multiple term slugs or IDs, separated by commas. Alternatively, you can select a magic field from the dropdown menu to dynamically populate the filter terms based on the selected field when the grid loads. This can be useful for filtering the grid based on the page title, the terms attached to a post, or specific post IDs. For example, you could use a magic field to automatically filter content based on the category of the current page, allowing the grid to dynamically display only the most relevant posts.

Only Attach Terms to the Current Post

This option is only applicable to the Taxonomy filter. By selecting this, the grid will only include terms attached to the current post.