[wp-hackers] overriding a class method for just one theme
ghodmode at ghodmode.com
Sun Dec 6 10:12:24 UTC 2009
If I extend a WordPress class and override one or more methods, is there
a common convention that I should follow for where I define my class?
Right now I only need it for a specific theme I'm working on, but I'll
probably want to use this again, so I don't think I should put it into
functions.php for the theme I'm working on.
Should I create my own includes directory either from the document root
or the theme's directory (ie: /wp-content/themes/mytheme/includes), and
put the php file containing the class in there?
Here's the context:
I want wp_list_categories() to put the count of posts for each category
inside of the text of the link for the categories section of the
sidebar. After looking through the code, I've decided that I should
create my own class to extend Walker_Category (which extends Walker)
(classes.php) and override the display_element() method (from Walker) so
that it does what I want.
Is this the right way to go about it?
More information about the wp-hackers