{
  "group": "query",
  "about": "Reusable query controls (T118/T213). A manifest adds them with \"controlGroups\": [\"query\"] or [{\"group\": \"query\", \"defaults\": {\"query_post_type\": \"product\"}}]; Zadex\\Loop\\ControlGroups (PHP) and src/editor/core/controlGroups.ts (JS) expand them, Zadex\\Loop\\Query turns the values into WP_Query args.",
  "sections": [
    { "id": "query", "label": "Query", "tab": "content" }
  ],
  "controls": [
    { "id": "query_source", "type": "select", "label": "Source", "tab": "content", "section": "query", "default": "post_type", "options": [
      { "value": "post_type", "label": "Post type" },
      { "value": "current", "label": "Current query" },
      { "value": "manual", "label": "Manual selection" },
      { "value": "related", "label": "Related posts" }
    ], "description": "Current query uses the posts of the archive or search page the loop is shown on." },
    { "id": "query_post_type", "type": "select", "label": "Post type", "tab": "content", "section": "query", "default": "post", "optionsFrom": "loopPostTypes", "condition": { "query_source": "post_type" } },
    { "id": "query_ids", "type": "text", "label": "Post IDs", "tab": "content", "section": "query", "default": "", "placeholder": "12, 34, 56", "dynamic": false, "condition": { "query_source": "manual" }, "description": "Comma separated. Any public post type." },
    { "id": "query_related_by", "type": "select", "label": "Related by", "tab": "content", "section": "query", "default": "category", "optionsFrom": "loopTaxonomies", "condition": { "query_source": "related" }, "description": "Posts sharing a term of this taxonomy with the current post." },

    { "id": "query_heading_filter", "type": "heading", "label": "Include / exclude", "tab": "content", "section": "query" },
    { "id": "query_taxonomy", "type": "select", "label": "Taxonomy", "tab": "content", "section": "query", "default": "category", "optionsFrom": "loopTaxonomies", "condition": { "query_source": ["post_type", "current", "related"] } },
    { "id": "query_terms", "type": "text", "label": "Include terms", "tab": "content", "section": "query", "default": "", "placeholder": "news, 12", "dynamic": false, "condition": { "query_source": ["post_type", "current", "related"] }, "description": "Slugs or IDs, comma separated. Use taxonomy:slug (post_tag:featured) for another taxonomy." },
    { "id": "query_terms_operator", "type": "select", "label": "Terms match", "tab": "content", "section": "query", "default": "IN", "options": [{ "value": "IN", "label": "Any term" }, { "value": "AND", "label": "All terms" }], "condition": { "query_source": ["post_type", "current", "related"] } },
    { "id": "query_exclude_terms", "type": "text", "label": "Exclude terms", "tab": "content", "section": "query", "default": "", "dynamic": false, "condition": { "query_source": ["post_type", "current", "related"] } },
    { "id": "query_authors", "type": "text", "label": "Include authors", "tab": "content", "section": "query", "default": "", "placeholder": "1, admin", "dynamic": false, "description": "User IDs or logins, comma separated." },
    { "id": "query_exclude_authors", "type": "text", "label": "Exclude authors", "tab": "content", "section": "query", "default": "", "dynamic": false },
    { "id": "query_exclude_ids", "type": "text", "label": "Exclude post IDs", "tab": "content", "section": "query", "default": "", "dynamic": false },
    { "id": "query_exclude_current", "type": "switch", "label": "Exclude current post", "tab": "content", "section": "query", "default": true },
    { "id": "query_avoid_duplicates", "type": "switch", "label": "Avoid duplicates", "tab": "content", "section": "query", "default": false, "description": "Skip posts already shown by loops above this one on the page." },

    { "id": "query_heading_date", "type": "heading", "label": "Date", "tab": "content", "section": "query" },
    { "id": "query_date", "type": "select", "label": "Date range", "tab": "content", "section": "query", "default": "any", "options": [
      { "value": "any", "label": "All time" },
      { "value": "day", "label": "Past day" },
      { "value": "week", "label": "Past week" },
      { "value": "month", "label": "Past month" },
      { "value": "year", "label": "Past year" },
      { "value": "custom", "label": "Custom" }
    ] },
    { "id": "query_date_after", "type": "text", "label": "After", "tab": "content", "section": "query", "default": "", "placeholder": "2026-01-31", "dynamic": false, "condition": { "query_date": "custom" } },
    { "id": "query_date_before", "type": "text", "label": "Before", "tab": "content", "section": "query", "default": "", "placeholder": "2026-12-31", "dynamic": false, "condition": { "query_date": "custom" } },

    { "id": "query_heading_order", "type": "heading", "label": "Order", "tab": "content", "section": "query" },
    { "id": "query_orderby", "type": "select", "label": "Order by", "tab": "content", "section": "query", "default": "date", "options": [
      { "value": "date", "label": "Date" },
      { "value": "modified", "label": "Last modified" },
      { "value": "title", "label": "Title" },
      { "value": "menu_order", "label": "Menu order" },
      { "value": "comment_count", "label": "Comment count" },
      { "value": "author", "label": "Author" },
      { "value": "ID", "label": "ID" },
      { "value": "post__in", "label": "Manual order" },
      { "value": "rand", "label": "Random" }
    ] },
    { "id": "query_order", "type": "select", "label": "Order", "tab": "content", "section": "query", "default": "DESC", "options": [{ "value": "DESC", "label": "Descending" }, { "value": "ASC", "label": "Ascending" }] },
    { "id": "query_per_page", "type": "number", "label": "Posts per page", "tab": "content", "section": "query", "default": 6, "min": 1, "max": 100 },
    { "id": "query_offset", "type": "number", "label": "Offset", "tab": "content", "section": "query", "default": 0, "min": 0, "max": 100 },
    { "id": "query_ignore_sticky", "type": "switch", "label": "Ignore sticky posts", "tab": "content", "section": "query", "default": true }
  ]
}
