Home Forums Front-end Issues Uncaught TypeError: Cannot read property 'query' of undefined


Uncaught TypeError: Cannot read property 'query' of undefined

  • Hi @steviec

    Great to hear that you solved it and thank you for posting your solution here for others to find 🙂

    • tabboy

    • September 3, 2016 at 8:36 pm

    Yes what StevieC said. Users need to have a minimum of an Author role in order to upload media files otherwise you get that non-descriptive error,

  • Might be interesting to know that it’s to upload files without permissions if you do it through acf_form() in the front end. However then it will always use the regular upload input type rather than WordPress native.

    Just some info for people that might find this topic.

    • tabboy

    • September 8, 2016 at 9:00 am

    I think it actually defaults to the basic uploader if you don’t have permissions. However, the gallery field is the control that does not work.

  • @tabboy
    Yeah that’s what I meant by:

    However then it will always use the regular upload input type rather than WordPress native.

    The gallery field needs WordPress core functionality to work so yeah that’d probably be a different case 🙂

  • This error occurs in Chrome Browser when you read a property or call a method on an undefined object . Uncaught TypeError: Cannot read property of undefined error is probably easiest to understand from the perspective of undefined, since undefined is not considered an object type at all (but its own undefined type instead), and properties can only belong to objects within JavaScript. There are a few variations of this error depending on the property you are trying to access. Sometimes instead of undefined it will say null.

    • lflood

    • November 2, 2019 at 8:58 am

    Hello all,

    I am also getting the same error as @tabboy but on line 10260 in acf-input.js. I have an Image field inside of a repeater and when I click on ‘Add Image’, I receive an “Uncaught TypeError: Cannot read ‘query’ of undefined” for the following:

    var Query = options.library );

    I am using WordPress 5.2.4 and ACF Pro Version 5.8.6.

    I would also like to mention that this is happening on a Charitable campaigns post in the backend. Here is a reference to that plugin:

    To test whether it has something to do with the repeater, I created a new field group with just an Image field to show on my campaign post but that also didn’t work so the repeater is not at fault. For some reason, the media modal is not opening up as it should.

    I have tried this on both Chrome and Firefox with no luck.

    Any help is much appreciated! Thank you!

  • Hi,
    I have read all the post. Have the same problem, but inside the editor of pages (where my admin upload posts.. not public)

    The error raises upon pressing the “upload image” button. No dialog appears.

    Console error is:

    acf-input.min.js?ver=5.8.7:3 Uncaught TypeError: Cannot read property 'query' of undefined
        at n.addFrameStates (acf-input.min.js?ver=5.8.7:3)
        at n.initialize (acf-input.min.js?ver=5.8.7:3)
        at n.e (acf-input.min.js?ver=5.8.7:1)
        at n.acf.Model (acf-input.min.js?ver=5.8.7:1)
        at n [as constructor] (acf-input.min.js?ver=5.8.7:1)
        at new n (acf-input.min.js?ver=5.8.7:1)
        at Object.acf.newMediaPopup (acf-input.min.js?ver=5.8.7:3)
        at n.selectAttachment (acf-input.min.js?ver=5.8.7:2)
        at n.onClickAdd (acf-input.min.js?ver=5.8.7:2)
        at n.<anonymous> (acf-input.min.js?ver=5.8.7:1)

    Wordpress ver 5.3.1

    All plugins updated

    any ideas? I’m driving mad.


    • lflood

    • December 19, 2019 at 9:42 am


    My error was happening on a custom post type created by a plugin called Charitable that allows for ACF fields on the page. I reached out to them about the JavaScript errors since they weren’t occurring on any other of my custom post types. They responded saying that it’s an issue related to a bug that happens with their Recurring Donations extension when it is not installed alongside their plugin.

    So the solution for me was to install the extension and luckily that fixed everything.

    Are you editing WordPress pages or pages from a plugin? If it is from a plugin, I would try contacting them.

    Best of luck!

    • RNR GFX

    • November 18, 2020 at 9:05 pm

    Hi all.
    I know this is an old thread now, but what did the trick for me (on WP 5.5.3 and ACF PRO 5.9.3) is just adding this to the template I’m working on:


Viewing 10 posts - 26 through 35 (of 35 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.