WordPress is the most used tool that makes it easy to develop a low-maintenance website. You can use WordPress to build different types of websites, such as blogs, eCommerce shops, businesses, and charity sites. Here we have added some small code that is useful without much-needed technical knowledge.
How to core reinstall WordPress?
When you go to WordPress updates, you might see “Re-install version” if your WordPress is outdated. Clicking this will prompt you for Hostname, FTP username, and password. If you have these credentials, enter them;

Add the line below code to your wp-config.php
file in the root folder.
define( 'FS_METHOD', 'direct' );
How to disable the WordPress admin bar for non admin or specific users?
WordPress admin black bar sometimes we want to disable for specific user role or everyone except admin user, so you can add the below code in your theme inside function.php
without installing any plugin.
Remove for all users then use below code except for admin user
add_action('after_setup_theme', 'remove_admin_bar_twc');
function remove_admin_bar_twc() {
if (current_user_can('editor') || !current_user_can('administrator')) {
show_admin_bar(false);
}
}
Remove for specific user role then use the below code
add_action('after_setup_theme', 'remove_admin_bar_specific_twc');
function remove_admin_bar_specific_twc() {
if (current_user_can('editor')) {
show_admin_bar(false);
}
}
How to get rid of a specific menu item from the WordPress admin bar?
In the WordPress admin bar, there are often many menu options and one-click action URLs that may not be helpful when developing a white label website. It is better to remove these using simple code instead of installing a plugin.
add_action('wp_before_admin_bar_render','remove_menu_items_twc');
function remove_menu_items_twc()
{
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo'); // remove wordpress logo
$wp_admin_bar->remove_menu('comments'); // remove comment saymbol
$wp_admin_bar->remove_menu('search'); // remove search icon right hand side
}
If you need help with removing the menu, please reach out to us. Contact Us
How to allow SVG upload in the WordPress media library?
When we try to upload SVG images in WordPress we face the error “Sorry, you are not allowed to upload this file type.”, So that time we can add one simple code below in function.php
the file, there is no need for any plugin for this type of issue.
add_filter('upload_mimes', 'mime_types_allow_twc');
function mime_types_allow_twc($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
If you need to upload other extension files in media then ping us.
How to reduce WordPress database size?
Here is a simple one-line code that helps prevent the generation of new rows in the database. When we write a blog or design a website using builders like Elementor, our content is automatically saved every 60 seconds. Each time this occurs, a new row is created in the database, which can lead to a large number of rows as we add more blogs. This can negatively impact our website’s speed. Therefore, it is suggested to limit revisions. Below code you can put in wp-config.php
define('WP_POST_REVISIONS', 3);
If you do not want a revision, please replace the number 3 with false
in the line above. Above code is just a simple trick, many more tricks and plugins available in the market to reduce database size.