[wp-hackers] execPHP question

IC IC icwordpress at gmail.com
Tue Nov 1 10:43:46 UTC 2011


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?


More information about the wp-hackers mailing list