7 WordPress tips and hacks to make use of on each web site

Though WordPress is de facto highly effective CMS there are some annoying issues I wish to be deactivated by default. For instance, I don’t see the explanation why commenting needs to be enabled by default. Due to this fact, as we speak I’m going to indicate you 7 greatest WordPressi tips I‘m utilizing on each web site.

Earlier than we begin it’s essential know that it’s essential add all of the code snippets right here beneath both to your little one theme’s capabilities.php file or higher but, inside Code Snippets plugin code field.

Disable WordPress feedback with no plugin

As a substitute of utilizing a Disable Feedback plugin (or comparable) you’ll be able to do away with the remark space through the use of this snippet right here.

// Disable feedback
operate __disable_feature($knowledge) { return false; }
add_filter('comments_number', '__disable_feature');
add_filter('comments_open', '__disable_feature');

Take away Emojis

Why would one need to achieve this? Nicely, take me for instance. I haven’t use any emojis on my websites for years and I’m not planning to make use of them both. However, since they’re activated by default, then each time you load a web page an emoji script is loaded. Due to this fact, I’m eradicating emoji script to scale back the web page load measurement and requests.

// Take away Emojis
add_action( 'init', 'generate_disable_wp_emojicons' );
operate generate_disable_wp_emojicons() 
{
	// all actions associated to emojis
	remove_action( 'admin_print_styles', 'print_emoji_styles' );
	remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
	remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
	remove_action( 'wp_print_styles', 'print_emoji_styles' );
	remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
	remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
	remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
}

Unregister pointless WordPress widgets

WordPress Widgets space is loaded with all kinds of widgets 95% customers received’t want. Take Archive or Calendar widgets for instance. So, with this little code snippet right here beneath you’ll be able to take away these widgets you don’t want and unclutter your widgets space.

// Unregister widgets
operate unregister_default_widgets() {
unregister_widget('WP_Widget_Pages');
unregister_widget('WP_Widget_Calendar');
unregister_widget('WP_Widget_Archives');
unregister_widget('WP_Widget_Links');
unregister_widget('WP_Widget_Meta');
unregister_widget('WP_Widget_Categories');
unregister_widget('WP_Widget_RSS');
unregister_widget('WP_Widget_Media_Audio');
unregister_widget('WP_Widget_Media_Video');
unregister_widget( 'WP_Widget_Tag_Cloud' );
}
add_action('widgets_init', 'unregister_default_widgets', 11);

Take away WordPress dashboard widgets

Now let’s modify a WordPress dashboard which can be stuffed with pointless widgets. Sure, you’ll be able to flip then off underneath Display choices by I prefer to deactivate them for all customers. So, seize this code and take away WordPress dashboard widgets you don’t want.

operate remove_widgets() {

	remove_meta_box( 'dashboard_primary','dashboard','facet' ); // WordPress.com Weblog
	remove_meta_box( 'dashboard_plugins','dashboard','regular' ); // Plugins
	remove_meta_box( 'dashboard_right_now','dashboard', 'regular' ); // Proper Now
	remove_action( 'welcome_panel','wp_welcome_panel' ); // Welcome Panel
	remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel'); // Strive Gutenberg
	remove_meta_box('dashboard_quick_press','dashboard','facet'); // Fast Press widget
	remove_meta_box('dashboard_recent_drafts','dashboard','facet'); // Latest Drafts
	remove_meta_box('dashboard_secondary','dashboard','facet'); // Different WordPress Information
	remove_meta_box('dashboard_incoming_links','dashboard','regular'); //Incoming Hyperlinks
	remove_meta_box('rg_forms_dashboard','dashboard','regular'); // Gravity Kinds
	remove_meta_box('dashboard_recent_comments','dashboard','regular'); // Latest Feedback
	remove_meta_box('icl_dashboard_widget','dashboard','regular'); // Multi Language Plugin
	remove_meta_box('dashboard_activity','dashboard', 'regular'); // Exercise
	remove_meta_box('dashboard_site_health', 'dashboard', 'regular'); // Website well being
	remove_meta_box( 'e-dashboard-overview', 'dashboard', 'regular'); // Elementor
}
add_action( 'wp_dashboard_setup', 'remove_widgets' );

Add file measurement column to your WordPress Media listing desk

Because the heading says, this snippet right here beneath provides a file measurement column so you’ll be able to see how large are the uploaded recordsdata with out the necessity to open each file one by one.

<span position="button" tabindex="0" data-code="add_filter( 'manage_media_columns', 'sk_media_columns_filesize' );
/**
* Filter the Media listing desk columns so as to add a File Dimension column.
*
* @param array $posts_columns Current array of columns displayed within the Media listing desk.
* @return array Amended array of columns to be displayed within the Media listing desk.
*/
operate sk_media_columns_filesize( $posts_columns ) {
$posts_columns['filesize'] = __( 'File measurement', 'my-theme-text-domain' );

return $posts_columns;
}

add_action( 'manage_media_custom_column', 'sk_media_custom_column_filesize', 10, 2 );
/**
* Show File Dimension customized column within the Media listing desk.
*
* @param string $column_name Title of the customized column.
* @param int $post_id Present Attachment ID.
*/
operate sk_media_custom_column_filesize( $column_name, $post_id ) {
if ( 'filesize' !== $column_name ) {
return;
}

$bytes = filesize( get_attached_file( $post_id ) );

echo size_format( $bytes, 2 );
}

add_action( 'admin_print_styles-upload.php', 'sk_filesize_column_filesize' );
/**
* Modify File Dimension column on Media Library web page in WP admin
*/
operate sk_filesize_column_filesize() {
echo
'

  • Learn how to create, take away, rename and re-order Woocommerce product tabs?
  • Learn how to Disguise Woocommerce Checkout Fields When Native Pickup is Chosen?
  • Wocommerce: Learn how to Give a Low cost to Native Pickup?

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart
Scroll to Top