Skip to content

This plugin adds widgets and sidebar queries to WPGraphQL.

Notifications You must be signed in to change notification settings

snibbo71/wp-graphql-widgets

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WPGraphQL Widgets (Queries)

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.

Requirements

Installation

You can install and activate it just like any other WordPress plugin.

Usage

Widget Examples

  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
          }
        }
      }
    }
  }

Rendered field

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 Examples

  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
          }
        }
      }
    }
  }

About

This plugin adds widgets and sidebar queries to WPGraphQL.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%