Wp meta value for dropdown box in custom post

时间:2018-02-05 12:59:53

标签: wordpress custom-post-type post-meta

I have added one custom post in admin side for adding session details.Inside session post i want to add a speaker data by using dropdown box.but the data is stored in the post meta as "a:2:{i:0;s:2:"91";i:1;s:3:"105";}"

Here 91 and 105 are the ID's of speaker post.

Can anyone suggest me how can parse the data from the metadata.

1 个答案:

答案 0 :(得分:0)

您的扬声器元数据采用序列化格式。只需使用get_post_meta( $session_id, '_speaker_meta_id', true );,您就可以将扬声器数据作为数组获得,然后您可以随心所欲地执行任何操作。 get_post_meta()自动反序列化序列化数据。

有关get_post_meta()的详细信息,请查看此https://developer.wordpress.org/reference/functions/get_post_meta/