[wp-trac] [WordPress Trac] #22956: Unpredictable template loading when multiple post types are involved

WordPress Trac noreply at wordpress.org
Sun Dec 16 00:15:02 UTC 2012


#22956: Unpredictable template loading when multiple post types are involved
--------------------------+--------------------
 Reporter:  scribu        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  3.5.1
Component:  General       |     Version:  3.5
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+--------------------
Description changed by scribu:

Old description:

> [21861] sought to improve the template loading behaviour when multiple
> post types are involved, but I don't think it was the right approach.
>
> 1. It creates backward-incompatible behaviour:
>
> Take a query of `'post_type' => array( 'serie', 'post' )`
>
> In 3.4, `archive.php` always ended up being loaded, since it was unlikely
> for `archive-Array.php` to exist.
>
> In 3.5, it unexpectedly loads `archive-serie.php`.
>
> 2. Which template gets loaded depends on the order of the post types,
> i.e. `'post_type' => array( 'serie', 'post' )` is different from
> `'post_type' => array( 'post', 'serie' )`.
>
> Possible alternatives:
>
> a) always load `archive.php` if 'post_type' is an array.
>
> b) choose the template based on `get_queried_object()`.

New description:

 [21861] sought to improve the template loading behaviour when multiple
 post types are involved, but I don't think it was the right approach.

 '''1. It creates backward-incompatible behaviour.'''

 Take a query of `'post_type' => array( 'serie', 'post' )`

 In 3.4, `archive.php` always ended up being loaded, since it was unlikely
 for `archive-Array.php` to exist.

 In 3.5, it unexpectedly loads `archive-serie.php`.

 '''2. The order of the post types becomes important.'''

 For example, `'post_type' => array( 'serie', 'post' )` can potentially
 load a different template from `'post_type' => array( 'post', 'serie' )`.

 Possible alternatives:

 a) always load `archive.php` if 'post_type' is an array.

 b) choose the template based on `get_queried_object()`.

--

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22956#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list