Make WordPress Core

Changeset 12010


Ignore:
Timestamp:
10/08/2009 05:27:51 PM (15 years ago)
Author:
westi
Message:

Allow for tag templates to be linked by tag id as well as name. Fixes #10868.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/theme.php

    r11971 r12010  
    619619 * Retrieve path of tag template in current or parent template.
    620620 *
    621  * Works by retrieving the current tag name, for example 'tag-wordpress.php' and will
    622  * fallback to tag.php template, if the name tag file doesn't exist.
    623  *
     621 * Works by first retrieving the current tag name, for example 'tag-wordpress.php' and then
     622 * trying tag ID, for example 'tag-1.php' and will finally fallback to tag.php
     623 * template, if those files don't exist.
     624 *
    624625 * @since 2.3.0
    625626 * @uses apply_filters() Calls 'tag_template' on file path of tag template.
     
    628629 */
    629630function get_tag_template() {
    630     $template = locate_template(array("tag-" . get_query_var('tag') . '.php', 'tag.php'));
     631    $tag_id = absint( get_query_var('tag_id') );
     632    $tag_name = get_query_var('tag');
     633
     634    $templates = array();
     635
     636    if ( $tag_name )
     637        $templates[] = "tag-$tag_name.php";
     638    if ( $tag_id )
     639        $templates[] = "tag-$tag_id.php";
     640    $templates[] = "tag.php";
     641   
     642    $template = locate_template($templates);
    631643    return apply_filters('tag_template', $template);
    632644}
Note: See TracChangeset for help on using the changeset viewer.