Support » Developing with WordPress » get_post_meta not returning value

Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    The leading underscore is an informal “private” designation which indicates we should not be directly using the value. There’s normally no technical reason you couldn’t do so anyway. It’s possible the plugin that established the field is also somehow hooked into get_post_meta() in a way that prevents us from getting the value.

    Try placing your test code temporarily on a twentyseventeen template file, then install and activate the health-check plugin. Activate troubleshooting mode in the plugin. In that mode, make a request involving the template with your test code. If it works through this mode, there’s either some sort of conflict or intentional code preventing your code from working.

    You can activate plugins one by one using the troubleshooting item in the admin bar. When your code again fails will tell you if it’s a conflict or intentional. If you can narrow down the source to the precise code responsible, it can be circumvented.

    You could also try getting the value directly through an SQL query. Also, if you are trying to get this value immediately after it’s first saved, you may have a race condition where your code executes before the value can be written to the DB.

Viewing 1 replies (of 1 total)
  • The topic ‘get_post_meta not returning value’ is closed to new replies.