The Fix
(Will mark as resolved once included with initial download of WordPress.)
The code below will make it work the way the Codex says it should.
https://joshbruce.com/tag_url/
Until this is included with WordPress itself – if you use %tag% in your permalink structure – get_permalink(), the_permalink(), and automatic comment redirect functionality will not work properly.
Also, there should be an inclusion of a default “Tag Base” portion added to the code (similar to the $category section); however, I don’t need it right now.
File: /includes/link-template.php
Function: get_permalink();
Changes are commented via standard PHP ‘//’ comment method.
/**
* Retrieve full permalink for current post or post ID.
*
* @since 1.0.0
*
* @param int $id Optional. Post ID.
* @param bool $leavename Optional, defaults to false. Whether to keep post name or page name.
* @return string
*/
function get_permalink($id = 0, $leavename = false) {
$rewritecode = array(
'%year%',
'%monthnum%',
'%day%',
'%hour%',
'%minute%',
'%second%',
$leavename? '' : '%postname%',
'%post_id%',
'%category%',
'%tag%', // removes %tag% delimiter
'%author%',
$leavename? '' : '%pagename%',
);
if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter )
$post = $id;
else
$post = &get_post($id);
if ( empty($post->ID) ) return false;
if ( $post->post_type == 'page' )
return get_page_link($post->ID, $leavename);
elseif ($post->post_type == 'attachment')
return get_attachment_link($post->ID);
$permalink = get_option('permalink_structure');
if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending')) ) {
$unixtime = strtotime($post->post_date);
// begin permalink inclusion for %tag%
$tag = '';
if ( strpos($permalink, '%tag%') !== false ){ // found %tag% in permalink structure
$tags = get_the_tags($post->ID); // get associated tags (array)
if ( $tags ) {
usort($tags, '_usort_terms_by_ID'); // order by ID
$tag = $tags[0]->slug; // use the lowest number tag
}
}
// end coding for %tag% replacemnt
$category = '';
if ( strpos($permalink, '%category%') !== false ) {
$cats = get_the_category($post->ID);
if ( $cats ) {
usort($cats, '_usort_terms_by_ID'); // order by ID
$category = $cats[0]->slug;
if ( $parent = $cats[0]->parent )
$category = get_category_parents($parent, false, '/', true) . $category;
}
// show default category in permalinks, without
// having to assign it explicitly
if ( empty($category) ) {
$default_category = get_category( get_option( 'default_category' ) );
$category = is_wp_error( $default_category ) ? '' : $default_category->slug;
}
}
$author = '';
if ( strpos($permalink, '%author%') !== false ) {
$authordata = get_userdata($post->post_author);
$author = $authordata->user_nicename;
}
$date = explode(" ",date('Y m d H i s', $unixtime));
$rewritereplace =
array(
$date[0],
$date[1],
$date[2],
$date[3],
$date[4],
$date[5],
$post->post_name,
$post->ID,
$category,
$tag, // for implosion of permalink
$author,
$post->post_name,
);
$permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink);
$permalink = user_trailingslashit($permalink, 'single');
return apply_filters('post_link', $permalink, $post, $leavename);
} else { // if they're not using the fancy permalink option
$permalink = get_option('home') . '/?p=' . $post->ID;
return apply_filters('post_link', $permalink, $post, $leavename);
}
}