Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I downloaded the PODS 2 plugin (amazing!) - added a field to existing content type and now I would like to print it using php inside a widget. However I am not sure how to print the fields using pods - I tried to initialize it, but it is not working. Please see my code below. Any ideas?

<?php $mypod = pods( 'my_pod' );
 $mypod->display( 'my_field' ); ?>

http://staging.pods.io/docs/code/pods/

share|improve this question

1 Answer 1

display does not echo, so you need to echo it.

<?php echo $mypod->display( 'my_field' ); ?>

More info and examples at http://staging.pods.io/docs/code/pods/display/

Also you will need to specify an ID of the item you want the field from in the pods() call, like:

<?php $mypod = pods( 'my_pod', $id ); ?>

Or use a find() call to get the record you want. http://staging.pods.io/docs/code/pods/find/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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