Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter ogwebchef

    (@ogwebchef)

    proper query

    query graballmenuitems {
      menus(where: {id: 32}) {
        edges {
          node {
            menuItems(first: 11) {
              edges {
                node {
                  label
                  uri
                }
              }
            }
          }
        }
      }
    }
    • This reply was modified 3 years, 11 months ago by ogwebchef.
    Thread Starter ogwebchef

    (@ogwebchef)

    Hi again,

    I managed to find a workaround and thought I’d share it with the community.

    If anyone else has any suggestion to final solution or alternative feel free to share it.

    Main menu items will be managed by WordPress Backend > Appearance > Menus and all remaining items I have created a parent page and sub-pages assigned to parent with specific keywords assigned to parent/sub pages.

    From there I created the following sample query which works for me

    {
      pages(
        where: {search: "random keyword", parent: "1", orderby: {field: MENU_ORDER, order: DESC}}
        first: 11
      ) {
        nodes {
          title
          parentId
          slug
        }
      }
    }

    This will query 10+ pages and return page title, parentid and slug which is perfect for my case use in making a nav menu with more than ten items.

    Hope this helps someone!

    Edit: After replying, looked deeper into my previous queries and found a much more easier solution.

    See query below:

    query graballmenuitems {
      menus(where: {id: 1}) {
        edges {
          node {
            menuItems(first: 11) {
              edges {
                node {
                  label
                }
              }
            }
          }
        }
      }
    }
    • This reply was modified 3 years, 11 months ago by ogwebchef.
    • This reply was modified 3 years, 11 months ago by ogwebchef. Reason: typos
    • This reply was modified 3 years, 11 months ago by ogwebchef. Reason: Found a simpler solution
    • This reply was modified 3 years, 11 months ago by ogwebchef. Reason: bold edit
    ogwebchef

    (@ogwebchef)

    Hi, were you able to figure it out? What happens when you add to query “first: 230” or vice versa “last: 230”

    I am able to query unlimited posts but not menus which is bizarre.

    Thread Starter ogwebchef

    (@ogwebchef)

    ogwebchef

    (@ogwebchef)

    I’m able to query unlimited amount of posts but limited to query up to 10 menu items. Why is that?

    add_filter( 'graphql_connection_max_query_amount', function( $amount, $source, $args, $context, $info  ) {
        if(current_user_can( 'manage_options')) {
             $amount = 1000; // increase post limit to 1000
        }
        return $amount;
    }, 10, 5 );

    ^^ Do I need to add to function to also remove query limit for menu items?

    • This reply was modified 4 years ago by ogwebchef.
    ogwebchef

    (@ogwebchef)

    Hi, this indeed does not work at all, including the solution offered by plugin author. I tested with wp 6.0 will test again with wp 5.8 to see if that’s the issue.

Viewing 6 replies - 1 through 6 (of 6 total)