Hide Visibility Option From WordPress Publish Metabox

Add this code: function wpseNoVisibility() { echo ‘<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</style>’; } add_action(‘admin_head’, ‘wpseNoVisibility’); to functions.php of your active theme. Needless to say, the preferred method, would be to add above code to functions.php of the child theme. Update Unfortunately, the above solution will not limit this change to pages only. We’ll have to determine, if we add, … Read more

Make “Post published. View post” Open in a New Tab

Open WP-Admin Editing File: Open the file located at: /example.com/public_html/wp-admin/edit-form-advanced.php Edit: Edit these lines to look like the next, adding target=”_blank” to each link or pasting the whole list. $messages = array(); $messages[‘post’] = array( 0 => ”, // Unused. Messages start at index 1. 1 => sprintf( __(‘Post updated. <a href=”https://wordpress.stackexchange.com/questions/173819/%s”>View post</a>’), esc_url( get_permalink($post_ID) … Read more

Color picker for posts and pages

I have found the solution on Denis Žoljom’s post 1) – I have added the metabox like this add_action( ‘add_meta_boxes’, ‘mytheme_add_meta_box’ ); if ( ! function_exists( ‘mytheme_add_meta_box’ ) ) { function mytheme_add_meta_box(){ add_meta_box( ‘header-page-metabox-options’, esc_html__(‘Header Color’, ‘mytheme’ ), ‘mytheme_header_meta_box’, ‘page’, ‘side’, ‘low’); } } 2) – enqueue the color picker style and script add_action( ‘admin_enqueue_scripts’, … Read more

Hide pages depending on role

To get the current role of the user $current_user = wp_get_current_user(); if ( !($current_user instanceof WP_User) ) return; $roles = $current_user->roles; //$roles is an array After getting role set page ids which you want to show according to roles (for example) if($roles==’administrator’){ $args=array(’21’,’22’,’23’); } or if($roles==’subscriber’){ $args=array(’24’,’25’,’26’); } you can use parse_query filter hook to … Read more

File exceeds upload_max_filesize, despite max filesize being large enough

Apparently there’s an upload_size_limit filter in WordPress. To check what your site’s upload limit is set to, add this to your theme’s functions.php: add_action( ‘shutdown’, ‘wpse115322_upload_sizes’, 99 ); function wpse115322_upload_sizes() { $size = wp_max_upload_size(); $kb = $size/1024; $mb = $size/(1024*1024); echo( “$kb KB / $mb MB<br />\n” ); } That’ll print your site’s actual max … Read more