[wp-hackers] custom_post_type and custom taxonomy naming

Peter Westwood peter.westwood at ftwr.co.uk
Mon Aug 23 07:03:30 UTC 2010

On 23 Aug 2010, at 02:56, Lox wrote:

> 2010/8/23 Andrew Nacin <wp at andrewnacin.com>
>> I'm not sure why it should. We introduced get_template_part() in order to
>> DRY up code. single.php has its own code that isn't used elsewhere; same
>> with page.php.
>> If you want to override page.php, you can do so, on a number of different
>> hooks or via a child theme. get_template_part() was not designed for plugin
>> overrides as much as child theme overrides.
> Ok let me explain and use an example.
> I have made, for a website, a quiz plugin. I *need* a page to hold it, so it
> can be moved, ordered, added to a nav menu, title can be managed using the
> page form etc. I can't use a shortcode to let the user put the quiz on the
> page he likes, because page content can be parsed many times per page
> request (like if u use Otto's SFC plugin) So, in my plugin settings page,
> the user selects, from a dropdown, the page to use as the quiz's page
> holder.
> As long as it is for a specific web site, I can use a theme template adding
> my template tag (or a do_action witch I prefer) to display the quiz: that
> will reflect the site specific theme and it is ok.
> But what happens if I make such plugin public? I will make a copy of the
> 2010 whole page.php to a template folder of my plugin. So out of the box,
> the quiz will use a template based on 2010, and if the user uses a different
> theme, the bundled page.php template won't fit. So what? I must give
> instruction to tell the user how to make its own template for the quizz, and
> thus have to maintain two page.php (his and the quiz's) whereas there is
> only one line that changes .... That is tedious ...
> Now if page.php was using get_template_part(), I could simply hook into
> get_template_part_{$slug} to use a bundled template part. So, my plugin will
> feets in user's theme out of the box (as long as his theme reflect the
> template layout of 2010 theme witch is the way to do)

The best solutions here are to create a template tag for theme authors to use, create a shortcode for users to use or to overload the contents of the main query and insert your quiz data in the place of the post data.

All of these are much better than trying to bundle extra page templates which won't match most themes

Peter Westwood
http://blog.ftwr.co.uk | http://westi.wordpress.com
C53C F8FC 8796 8508 88D6 C950 54F4 5DCD A834 01C5

More information about the wp-hackers mailing list