0

Pages label in red

I want to change the search pages label and remove the numbers of items.

I Want also to modify the number of the visible pages on the listing of the pages now it's 20 pages.

Solution :

function wpd_change_page_labels( $labels ) {

    $labels->search_items  = 'put the new name';
    return $labels;
}
add_filter( 'post_type_labels_page', 'wpd_change_page_labels' );
0

To change Number of items per page in Screen Options, add this code to functions.php of your theme:

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' );

This will change Number of items per page in Screen Options for all users. If you want to do it for selected users only, replace the line:

update_user_meta( $user_id, 'edit_page_per_page', $number_of_items );

with

$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, make and add the following script ( wpse_search_button.js ) to the root of your theme:

// JavaScript Document
jQuery( document ).ready(function($) {
    $('.displaying-num').css( 'display', 'none' );
    $('#search-submit').val( 'Look for Pages' );
});

Now add this to 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' );

This will hide number of items and change 'Search Pages' button label to 'Look for Pages'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.