I'm migrating an app to wordpress. We have thousands of wordpress posts that we will insert as custom_types in wordpress database. What is post_name field in wp_posts for? Can we have two records with the same post_name? Is it for friendly urls?
The post_name
is the post's slug. These must be unique.
Read more about WP_Post
member variables in the Codex.
It is correct that the post_name field stores the slug. However, the post_name field does not have a UNIQUE constraint in the MySQL schema, so while it should be unique, it is unfortunately not the case that it must be unique. Developers of plugins or tools that write to this table should mind this distinction as the wp_posts table can be corrupted by inserting non-unique values into the post_name table.
I encountered the above issue while resolving a duplication caused by Advanced Custom Fields keying its field and field group definitions off of the contents of this field.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With