最合适的回答,由SO网友:Frank P. Walentynowicz 整理而成
To change Number of items per page in Screen Options, 将此代码添加到functions.php
您的主题:
function wpse_modify_screen_option() {
$number_of_items = 10; // change this to desired value
$screen = get_current_screen();
if ( $screen->id != \'edit-page\' )
return;
$user_id = get_current_user_id();
if ( $user_id ) {
update_user_meta( $user_id, \'edit_page_per_page\', $number_of_items );
}
}
function wpse_screen_option() {
add_action( \'load-edit.php\', \'wpse_modify_screen_option\' );
}
add_action( \'admin_menu\', \'wpse_screen_option\' );
这将更改所有用户在屏幕选项中每页的项目数。如果要仅对选定用户执行此操作,请替换该行:
update_user_meta( $user_id, \'edit_page_per_page\', $number_of_items );
使用
$users = array( id1,...,idn, ); // replace id1 to idn with user ids
if ( in_array( $user_id, $users ) )
update_user_meta( $user_id, \'edit_page_per_page\', $number_of_items );
To change the search pages label and remove the numbers of items, 制作以下脚本(wpse\\u search\\u button.js)并将其添加到主题的根目录中:
// JavaScript Document
jQuery( document ).ready(function($) {
$(\'.displaying-num\').css( \'display\', \'none\' );
$(\'#search-submit\').val( \'Look for Pages\' );
});
现在将此添加到
functions.php
:
function wpse_load_admin_js() {
global $pagenow, $typenow;
if ( $pagenow == \'edit.php\' && $typenow == \'page\' ) {
wp_register_script( \'wpse-search-button-js\', get_stylesheet_directory_uri() . \'/wpse_search_button.js\', array( \'jquery\' ), false, true );
wp_enqueue_script( \'wpse-search-button-js\' );
}
}
add_action( \'admin_init\', \'wpse_load_admin_js\' );
这将隐藏项目数,并将“搜索页面”按钮标签更改为“查找页面”。