I'm trying to get the Post ID and the Post Type inside of my MU Plugin; functions like: get_the_ID() and get_post_type() return false, instead of the desire values.

I read that many functions are available after MU Plugins, not before.

So...Does anyone have tried to use Posts functions inside of MU Plugins? How do you resolve?

I'm thinking to use a query database to get the post metadata, but I don't know how efficient will be this method.

Thanks, I'll really appreciate the answer.

  • 5
    when you try to access these things is important. just about everything your plugin does should be hooked to an action.
    – Milo
    Feb 4 '18 at 0:09
  • the problem is not the MU plugin, you will have the same problem with a regular plugin. the question is "when do you read this value ?" the post identifier is not defined before the action wp wordpress.stackexchange.com/questions/26537/…
    – mmm
    Feb 4 '18 at 0:10
  • Thanks for the answers. @mmm I'm trying to read that value before wp action. So that's the main problem. Feb 4 '18 at 0:13
  • What I'm trying to do is disable plugins like Plugin Organizer does but in the frontend side, I read their code and found that they use some query databases to get post information. What do you think about that method? Feb 4 '18 at 0:17
  • There's no true front-end/back-end distinction between plugins, just different hooks that plugins can hook into, so I don't really understand what you're trying to do. Regarding getting the post type, posts don't exist yet at wp, so I'm also not sure what you're trying to do with that. Feb 4 '18 at 2:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.