This plugin registers for each active widget a new widget type which exposes all settings of the widget (and for some widgets a rendered
field more here) and implements the WidgetInterface
which exposes the following fields.
WidgetInterface {
active
databaseId
html
id
idBase
title
type
}
It also adds sidebar queries.
You can install and activate it just like any other WordPress plugin.
widget(id: "nav_menu-3") {
... on WPNavMenuWidget {
navMenu
active
databaseId
html
id
idBase
}
}
widgets {
edges {
cursor
node {
type
title
idBase
id
html
databaseId
active
sidebar {
node {
databaseId
description
}
}
}
}
}
For the WPNavMenuWidget
, WPMediaImageWidget
, WPWidgetRecentPosts
, WPWidgetCategories
, WPWidgetPages
and WPWidgetRecentComments
types there is also rendered
field which is a connection to their WPGraphQL type. Here is an example which would give you the menu of a menu widget.
widget(id: "nav_menu-3") {
databaseId
id
... on WPNavMenuWidget {
rendered {
node {
menuItems {
nodes {
label
path
}
}
}
}
}
}
sidebar(sidebar: SIDEBAR) {
afterSidebar
afterTitle
afterWidget
beforeSidebar
beforeTitle
beforeWidget
class
databaseId
description
id
name
widgets {
edges {
cursor
node {
databaseId
}
}
}
}
sidebars {
edges {
cursor
node {
databaseId
name
id
description
class
beforeWidget
beforeSidebar
beforeTitle
afterWidget
afterTitle
afterSidebar
widgets {
nodes {
databaseId
}
}
}
}
}