[wp-hackers] execPHP question

Claude Needham gxxaxx at gmail.com
Tue Nov 1 16:03:55 UTC 2011


The actually insert does not use <?php etc. does it?
If you are doing your insert something like:

[?php global $post; ?]

[?php echo ("postid=" . $post->ID ); ?]

I would experiment with the following insert:

[?php global $post; echo ("postid=" . $post->ID ); ?]


Claude

On Tue, Nov 1, 2011 at 4:02 AM, IC IC <icwordpress at gmail.com> wrote:
> I added it but results have not changed. right now, I have this... the
> value does not get outputted! Echo outputs only what's in the " ".
>
> <?php
>  global $post;
> ?>
>
> <?php the_post();?>
> <hr>
> <?php echo ("postid=" . $post->ID ); ?>
> <hr>
> <?php echo ("the id is=" . the_ID() ) ; ?>
> <hr>
> <?php echo ("gettheid:" . get_the_ID()); ?>
> <hr>
> <?php
> $mypostid = get_the_ID();
> echo ( "mypostid:" . $mypostid);
> ?>
>
> <hr>
>
> <?php
> $this_page_id = $wp_query->post->ID;
> echo "after wp_query .... " . $this_page_id ;
> ?>
>
> the above code outputs this;
>
> postid=
> ------------------------------
> the id is=
> ------------------------------
> gettheid:
> ------------------------------
> mypostid:
> ------------------------------
>
> after wp_query ….
>
>
> On Tue, Nov 1, 2011 at 3:45 AM, Andy Charrington-Wilden <
> andycharrington at gmail.com> wrote:
>
>> 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
>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> 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