wordpress不显示分类列表title的bug
刚才把菜单栏清理了一下,就剩下about页面。于是把inove的分类列表提到menu栏,右边的sidebar也缩短了不少。
但是立马出现了一个新问题,菜单中鼠标移过去会有title信息遮住二级菜单,按照文档说明修改后却没有生效,如图:
首先,查了一下wp_list_categories函数的用法:http://codex.wordpress.org/Template_Tags/wp_list_categories,按照文档里描述的,把use_desc_for_title参数设置为0就行:
wp_list_categories('title_li=0&orderby=name&show_count=0&use_desc_for_title=1');
use_desc_for_title
(boolean) Sets whether a category’s description is inserted into the title attribute of the links created (i.e. <a title=”<em>Category Description</em>” href=”…). The default is true (category descriptions will be inserted). Valid values:
1 (True) – Default
0 (False)
查看wp-includes/classes.php中wp_list_categories函数定义才发现有bug:
1331 if ( $use_desc_for_title == 0 || empty($category->description) )
1332 $link .= 'title="' . sprintf(__( 'View all posts filed under %s' ), $cat_name) . '"';
1333 else
1334 $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description',
$category->description, $category ) ) ) . '"';
很显然,不管use_desc_for_title参数是0还是1都会显示title信息,无语了,稍微改动一下:
1331 if ( $use_desc_for_title == 1 && empty($category->description) )
1332 $link .= 'title="' . sprintf(__( 'View all posts filed under %s' ), $cat_name) . '"';
1333 else if($use_desc_for_title == 1 && !empty($category->description))
1334 $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
总算隐藏掉了分类列表的title信息了,如图





Linode VPS
Tengine