[wp-trac] [WordPress Trac] #19063: Custom post_types and get_template_part
WordPress Trac
wp-trac at lists.automattic.com
Thu Oct 27 17:38:55 UTC 2011
#19063: Custom post_types and get_template_part
-------------------------+------------------------------
Reporter: impleri | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Template | Version:
Severity: minor | Resolution:
Keywords: has-patch |
-------------------------+------------------------------
Comment (by impleri):
> Please try not to post big walls of text; it's hard to follow.
Apologies. I write/talk a lot (12+ years of uni does that!)
> I was hoping for a few short examples, in the form of: "When loading URL
X, with line of code Y, I can load template Z."
Which is why I provided a URL to an actual example I am working with. The
URL is for a custom post_type (ml_product) which has its own custom
metadata (book information). Since it is a CPT, most of its code is
standard WP handling. However, the template needs to display the book
metadata (authors, cover image, publication date, whatever). I currently
hack the entire template through the `archive_template` filter.
> I wasn't suggesting going lower down the stack, but higher i.e. to
get_archive_template() etc. as you later suggest.
Wouldn't going higher make it harder for template authors to provide their
own template? Also, using `get_*_template()` is already possible (through
the `*_template` filter called in `get_query_template()`). It still
requires plugins to output the entire template instead of the small
portion which they are adapting (i.e. `#div > #content`).
`get_template_part()` can handle that exact section.
> I attempt to tackle that with Theme Wrappers, but it's something that
theme authors must adopt.
I agree that everything should be reduced to a single wrapper, but I don't
see how Theme Wrappers does it any differently from `get_template_part()`.
In fact, what differences are there in `archive.php` and `single.php`
which cannot be resolved by using `get_template_part()` or abstracting
them into `loop-archive.php` and `loop-single.php` to complement the
`content-archive.php` and `content-single.php` files?
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19063#comment:10>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list