[wp-hackers] execPHP question

Haluk Karamete halukkaramete at gmail.com
Thu Nov 3 20:13:52 UTC 2011


Yes. This advise was right on the money.

so, this one works;
 [?php global $post; echo ("postid=" . $post->ID ); ?]

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

something to know about the way execPHP works..

Thank you Claude!

On Tue, Nov 1, 2011 at 9:18 AM, Andy Charrington-Wilden
<andycharrington at gmail.com> wrote:
> Good point yes. You'll need to wrap the global $post in the tags too.
>
>
> On 1 Nov 2011, at 16:03, Claude Needham wrote:
>
>> 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
>>>
>> _______________________________________________
>> 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