Manipulating the WordPress Admin
Displaying WordPress Media IDs in the Admin
Id of media files can be found, if in the admin panel in paragraph Media display all media files and point to the point Edit, but there is an easier way.
You can display id in a separate column. To display id media files in the admin panel, as a separate column, you can use the following filter. Add code to function.php.
1 2 3 4 5 6 7 8 9 10 11 |
function column_id($columns) { $columns['colID'] = __('ID'); return $columns; } add_filter( 'manage_media_columns', 'column_id' ); function column_id_row($columnName, $columnID){ if($columnName == 'colID'){ echo $columnID; } } add_filter( 'manage_media_custom_column', 'column_id_row', 10, 2 ); |
We replace the standard jquery library with the one suggested by google
If you, for some reason, the standard package of the jquery library that WordPress offers us is not satisfied, you can connect the library from google. Adding code to the function.php file.
1 2 3 4 5 6 7 8 |
add_action( 'init', 'jquery_register' ); function jquery_register() { if ( !is_admin() ) { wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', ( 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js' ), false, null, true ); wp_enqueue_script( 'jquery' ); } } |
1 2 3 4 |
function remove_editor_menu() { remove_action('admin_menu', '_add_themes_utility_last', 101); } add_action('_admin_menu', 'remove_editor_menu', 1); |
Hide pages from the admin from editing
This is a great little snippet., which will exclude pages, selection is based on ID from the list of pages. Just add this snippet to functions.php your topic WordPress and try to find those pages ID who you tried to hide.
1 2 3 4 5 6 7 8 9 |
add_action( 'pre_get_posts' ,'exclude_this_page' ); function exclude_this_page( $query ) { if( !is_admin() ) return $query; global $pagenow; if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'page' == get_query_var('post_type') ) ) $query->set( 'post__not_in', array(23,28,30) ); // page id return $query; } |
Checked everything, everything is working. Good luck with development!
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.