[wp-hackers] execPHP question

Andy Charrington-Wilden andycharrington at gmail.com
Tue Nov 1 10:45:20 UTC 2011

Have you added the global $post?

You'll need that to access the post object.


On 1 Nov 2011, at 10:43, IC IC wrote:

> I got the execPHP plug in installed. no problems with it as far as
> executing the php code thru the editor... for example, I tried the
> following the PHP snippet within the WYSIWYG editor and it works...
> [?php echo get_post_meta(1717, 'Ref', true); ?]
> it outputs the value stored within the custom field titled REF. And the
> 1717 happens to be the current post id of the post I was editing.
> but, whenever I tried to access post related data ( usually available in
> the wordpress loop ), nothing gets outputted. for example, the following
> produces nothing...
> [?php echo ("postid=" . $post->ID ); ?]
> Within the WYSIWYG editor, even the the_ID() outputs nothing. I thought, we
> were still in the wordpress loop and I could tap into any post related data
> at the moment.
> my goal was to replace the [?php echo get_post_meta(1717, 'Ref',
> true); ?]with [?php
> echo get_post_meta($post->ID, 'Ref', true); ?]
> What am I doing wrong?
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list