0

I tried to create a table output with the content of a custom post.

I can echo my city properly:

<span style="font-weight: bold;">city: </span>
<?php echo get_post_meta($post->ID, 'ptn_plaats', true);?>

But with this next line I get echo me ARRAY instead one of the options !!

<span style="font-weight: bold;">Systeem :</span>
<?php echo get_post_meta($post->ID, 'ptn_systeem', true);;?>

How can I echo the contents of my custom post type?

1
  • Please be aware that you have two semi-colons in your code: get_post_meta($post->ID, 'ptn_systeem', true);;
    – user9447
    Jul 23, 2016 at 2:30

2 Answers 2

1

You got ARRAY echos because you saved array on post meta,

Just check array values of meta data like:

print_r( get_post_meta($post->ID, 'ptn_systeem', true) );

and echo it like:

foreach( (array) get_post_meta($post->ID, 'ptn_systeem', true) as  $option):

    echo $option . "<br>";

endforeach;
0

Please go through serialize array concept in wp.In your postmeta it is storing data in serialised form if you are getting an array. Either you can loop through the array or to fetch a single record use the array key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.