Title: [Plugin: PHP Code Widget] Using and displaying data from the custom fields
Last modified: August 19, 2016

---

# [Plugin: PHP Code Widget] Using and displaying data from the custom fields

 *  Resolved [ucarmetin](https://wordpress.org/support/users/ucarmetin/)
 * (@ucarmetin)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-php-code-widget-using-and-displaying-data-from-the-custom-fields/)
 * Hello!
 * I’m using the plugin and must admit it has saved me a lot of time and effort.
   It works like charm.
 * However, I got a problem. I have a custom field where a sub title can be attached
   to the posts. I want this custom field to be displayed on the sidebar via the
   plugin. I wrote the appropriate code but it doesn’t display the value of this
   custom field. [Here](http://pastie.org/1277288) you can see my code. What am 
   I doing wrong?
 * [http://wordpress.org/extend/plugins/php-code-widget/](http://wordpress.org/extend/plugins/php-code-widget/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-php-code-widget-using-and-displaying-data-from-the-custom-fields/#post-1756852)
 * Code in the widget runs in a function call, and so you have to declare that you
   want access to global variables.
 * Try adding `<?php global $post; ?>` to the top of your code.
 *  Thread Starter [ucarmetin](https://wordpress.org/support/users/ucarmetin/)
 * (@ucarmetin)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-php-code-widget-using-and-displaying-data-from-the-custom-fields/#post-1756856)
 * Hej Otto,
 * Thanks for the help. The issue is resolved.
 * Regards!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: PHP Code Widget] Using and displaying data from the custom fields’
is closed to new replies.

 * ![](https://ps.w.org/php-code-widget/assets/icon.svg?rev=992095)
 * [PHP Code Widget](https://wordpress.org/plugins/php-code-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/php-code-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/php-code-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/php-code-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/php-code-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/php-code-widget/reviews/)

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)

 * 2 replies
 * 2 participants
 * Last reply from: [ucarmetin](https://wordpress.org/support/users/ucarmetin/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-php-code-widget-using-and-displaying-data-from-the-custom-fields/#post-1756856)
 * Status: resolved