你必须让你的网站类别与你的theme categories 文件夹名称。
以下是如何筛选主题:Hide a theme on list of themes in wp-admin without editing core files
然后,假设一个站点有a-p
主题存储在themes/a-p/
, 这将过滤掉它们:
add_filter( \'all_themes\', \'remove_themes_ms_wpse_117537\' );
function remove_themes_ms_wpse_117537( $themes )
{
if( \'site-themes-network\' != get_current_screen()->id )
return $themes;
$site_cat = get_blog_option( absint( $_GET[\'id\'] ), \'site_category\' );
if( $site_cat )
{
# Unset themes not in the folder /themes/$site_cat/
foreach( $themes as $key => $theme )
{
if( strpos( $key, "$site_cat/" ) === false )
unset($themes[$key]);
}
}
return $themes;
}