[wp-hackers] Idea to enhance the WP_Post class

Mike Schinkel mike at newclarity.net
Fri Apr 5 06:21:05 UTC 2013


On Apr 5, 2013, at 1:58 AM, Funkatron <funkatronic at gmail.com> wrote:
> I think your example already works in the current implementation.  

Nope. These instance properties are currently available:

$post->post_title;
$post->post_content;

But there are no instance properties like this:

$post->title;
$post->content;

However I'm not as interesting in what they are called but instead in how they work. I was suggesting being able to access via __get() not via instance properties.  Why?  Code like this with "virtual" properties implemented via __get() would work:

$html = "<a href='http://example.com/?p={$post->ID}'>{$post->title}</a>";

But PHP does not support code this:

$html = "<a href='http://example.com/?p={$post->the_ID()}'>{$post->the_title()}</a>";


> The reason I recommend the template tags because they use filters that you
> still may want to use in a secondary loop

My proposed example assumed filters too.  I should have been more explicit.

-Mike


More information about the wp-hackers mailing list