everyone
I would like to delete a value from the postmeta in my wordpress installation – and not a complete metavalue, but only part of the content in it.
e.g. metakey = test
metavalue = abba; dancing; queen;
and the "dancing" should be thrown out.
With update_post_meta and delete_post_meta I only manage to delete the complete metavalue or metakey.
update_post_meta( $id, ‘test’, $dancing);
delete_post_meta( $id, ‘test’, $dancing);
dont work 🙁
how can i remove only part of it?
lg
yeah
2
Answers
I think it works.
First I get the value of the previous postmeta.
Then we change it and finally save it in our post.
The order is as follows:
just remove the dancing word from the desired metavalue. You don’t have to serialize if meta value is an array, wordpress will automatically do it for you.
if $metavalue is array