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/

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/

Leave a Reply

Your email address will not be published. Required fields are marked *