Default value in register_post_meta

TIL: Defining a default value within register_post_meta drives you crazy if you no more aware of that you did it. It still persists, even if it is not in the database or the object cache.

Found out around an hour later … 🥲

Matze Avatar

Author:

As a developer, I work with WordPress every day. By day, I create plugins and themes, solve problems and sometimes produce new ones. At night, it’s not unusual to find me at the WordPress Meetup in Stuttgart with my dog. 🐕

Comments

Fediverse Reactions

3 responses to “Default value in register_post_meta”

  1. threadi Avatar

    @matze Feel with you

  2. Thomas Kräftner Avatar

    @matze post meta defaults are fun … https://core.trac.wordpress.org/ticket/55600 … not

    1. Matze Avatar

      This isn’t yet merged into core, isn’t it? I cannot stop the feeling to not use a default metadata value anymore in the future whatsoever and handle a default differently by checking get_post_meta for false instead.

Leave a Reply

Your email address will not be published. Required fields are marked *