Title: [Plugin: PHP Code Widget] PHP echo Custom Field
Last modified: August 19, 2016

---

# [Plugin: PHP Code Widget] PHP echo Custom Field

 *  Resolved [seemsse](https://wordpress.org/support/users/seemsse/)
 * (@seemsse)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/plugin-php-code-widget-php-echo-custom-field/)
 * Is it possible to use the PHP Code widget to display the results of a custom 
   field. I have tried to setup the PHP Code Widget to do this:
 * <?php echo get_post_meta($post->ID, “right feature”, true); ?>
 * but when I enter the custom field “right feature” nothing happens. Is this possible
   with the widget?
 * Thanks,
 * [http://wordpress.org/extend/plugins/php-code-widget/](http://wordpress.org/extend/plugins/php-code-widget/)

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

 *  [esenterre](https://wordpress.org/support/users/esenterre/)
 * (@esenterre)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/plugin-php-code-widget-php-echo-custom-field/#post-870768)
 * Is it possible to use the _include_ inside this widget. When I run my PHP code
   alone, it works fine, but when I try it inside that widget it seems to break.
 * I want to include the magpie rss reader…
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [17 years, 8 months ago](https://wordpress.org/support/topic/plugin-php-code-widget-php-echo-custom-field/#post-870769)
 * [@seemsse](https://wordpress.org/support/users/seemsse/): The code inside the
   widget runs inside a function scope, meaning that “$post” is undefined unless
   you declare it to be in the global scope.
 *     ```
       <?php
       global $post;
       echo get_post_meta($post->ID, "right feature", true);
       ?>
       ```
   
 * [@esenterre](https://wordpress.org/support/users/esenterre/): Yes, however it
   is difficult to say where your current location is when the code is running. 
   You should use the various defines to define the location of the included file
   precisely. Also, you should include_once it, to prevent it from loading twice.
   `
   include_once(ABSPATH . WPINC . '/rss.php');`
 *  Thread Starter [seemsse](https://wordpress.org/support/users/seemsse/)
 * (@seemsse)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/plugin-php-code-widget-php-echo-custom-field/#post-870789)
 * Otto42 –
 * Thank you so much, that worked great.
 *  [henigushi](https://wordpress.org/support/users/henigushi/)
 * (@henigushi)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/plugin-php-code-widget-php-echo-custom-field/#post-870877)
 * Hi Otto,
 * I’m using your plugin to make the latest post for a certain category appear in
   my sidebar, and it works great.
 * I am having a style problem, however. I have two widgets in my sidebar. One is
   yours, with the following code:
 *     ```
       <?php $recent = new WP_Query("cat=351&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
       <b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>
       <?php the_content(__('Read the story &raquo;'));?><div style="clear:both;"></div>
       <?php endwhile; ?>
       ```
   
 * The second is a text widget with two sentences in it.
 * My stylesheet separates widgets into blocks, all separated by a gray border. 
   Your plugin, however, combines the content of both widgets into a single block.
 * Is there a way to break them up? I’ve used <div> tags for both, without success.
 * Thanks!

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

The topic ‘[Plugin: PHP Code Widget] PHP echo Custom Field’ is closed to new replies.

 * 4 replies
 * 4 participants
 * Last reply from: [henigushi](https://wordpress.org/support/users/henigushi/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/plugin-php-code-widget-php-echo-custom-field/#post-870877)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
