[wp-hackers] Questions regarding extending WP_Post

Funkatron funkatronic at gmail.com
Wed Dec 4 01:38:31 UTC 2013


Hello, WP Hackers!  I have a few questions on the implementation of the
WP_Post class that WordPress uses.  I was wondering if there was a
technical reason why WP_Post is declared final?  I was doing some research
on ways to extend it and I found it strange that its declared final, making
it impossible to extend the class other than to copy, paste and editing the
code.  Was there a particular reason or was it just the coder's preference?

Second question is about posts and the filtered template functions like
the_title, the_content, etc.  Is there any reason why these functions
weren't included as methods of the WP_Post class?  To me it makes sense and
would allow coders to not rely on the global variables and functions in
secondary loops.  Instead of using the global variables via the_post or
using setup_postdata and having to call wp_reset_postdata afterwards to
clean everything up, you could call the methods os the WP_Post class.


More information about the wp-hackers mailing list