2012-10-15 36 views

回答

2

我試圖想辦法來幫助你,並用以下解決方案來。我基本上做的是製作一個額外的腳本,並將其放入後端。

製作一個名爲be-scripts.js的文件,並將其放在「theme_folder/js /」中。將下面的代碼放入其中:

(function($) { 

    // Select all categories 
    $('#categorychecklist').prepend('<li class="popular-category" id="category-all"><label class="selectit"><input type="checkbox" class="checkall" id="in-category-all" name="post_category[]"> Check all</label></li>'); 

    $('.checkall').click(function() { 
    $(this).parents('ul:eq(0)').find(':checkbox').attr('checked', this.checked); 
    }); 

})(jQuery); 

接下來,您需要將此腳本排入您網站的後端。你可以進入你的主題文件夾並打開functions.php。添加以下代碼:

function init_be_javascripts() { 
    if (is_admin()) { 
     wp_register_script('extra_be-script', get_template_directory_uri() . '/js/be-scripts.js', 'jquery', 0.1, true); 
     wp_enqueue_script('extra_be-script'); 
    } 
}  
add_action('init', 'init_be_javascripts'); 

如果一切順利,您可以在編輯帖子時選擇「全選」。

+0

工作就像一個魅力!謝謝@ravi – Chris

+0

非常歡迎! 〜_^B –

相關問題