WPJAM 插件在一些主题里(比如我现在用的主题),目录的中的隐藏和显示按钮有问题。因为有些主题为了加载快速把 JS 加载放在了 footer 里。而 WPJAM 插件把 js 放在了head 里,所以 jQuery 引用不行。

所以建议的把加载 js 和 css 写在 footer 中,修改方法见下面代码。

if(wpjam_basic_get_setting('toc_auto')){
add_action('wp_footer', 'wpjam_toc_footer');
function wpjam_toc_footer(){
if(is_singular()){
echo '<script type="text/javascript">'."\n".wpjam_basic_get_setting('toc_script')."\n".'</script>'."\n";
echo '<style type="text/css">'."\n".wpjam_basic_get_setting('toc_css')."\n".'</style>'."\n";
}
}
}

目录设置里的 CSS 我的是这样的

#toc {
/*float:right;*/
/*max-width:240px;*/
min-width:120px;
padding:6px;
margin:0 0 20px 0;
border:1px solid #EDF3DE;
background:white;
border-radius:6px;
}
#toc p {
margin:0 4px;
}
#toc strong {
border-bottom:1px solid #EDF3DE;
display:block;
}
#toc span {
display:block;
margin:4px 0;
cursor:pointer;
}
#toc ul{
margin-bottom:0;
}
#toc li{
margin:2px 0;
}
#toc small {
float:right;
}