-1

I will display post meta data with key 'jobfeature_zarobki'. This meta return following values:

jobfeature_zarobki : s:59:"a:2:{s:5:"label";s:7:"Zarobki";s:5:"value";s:8:"4800 zł";}";

I will display only '4800 zł'. How can I separate it?

Kamil Kostka
  • 31
  • 1
  • 5

1 Answers1

0

Use get_post_meta https://developer.wordpress.org/reference/functions/get_post_meta/ to access post meta.

amedv
  • 388
  • 1
  • 16
  • I know, but it gives "jobfeature_zarobki : s:59:"a:2:{s:5:"label";s:7:"Zarobki";s:5:"value";s:8:"4800 zł";}";" I need only this "4800 zł" value. $key = 'jobfeature_zarobki'; $myvals = get_post_meta($postid); foreach($myvals as $key=>$val) { echo $key . ' : ' . $val[0] . '
    '; }
    – Kamil Kostka Nov 28 '18 at 08:30
  • That is mean that you store value like that. It's serialized array, use `unserialize` http://php.net/manual/en/function.unserialize.php but it's not safe if this value passed from user (read note in function description) and also it may affect to speed performance. – amedv Nov 28 '18 at 15:44