.htaccess For WordPress In A Folder Without URL Change

.htaccess For WordPress In A Folder Without URL Change

By OutsourcedContent — on June 3, 2021 For quick reference. Remember to change my_subdir and example.com <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?example.com$ RewriteCond %{REQUEST_URI} !^/my_subdir/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /my_subdir/$1 RewriteCond %{HTTP_HOST} ^(www.)?example.com$ RewriteRule ^(/)?$ my_subdir/index.php [L] </IfModule> Reference: Giving WordPress Its Own Directory

Convert WordPress Image Filename To Lowercase

Convert WordPress Image Filename To Lowercase

By OutsourcedContent — on June 29, 2021 WordPress by default will preserve capitalisation in filename for images. To make filenames lowercase automatically, add the following to the functions.php of your active theme. /** * Convert filename to lowercase * * @author Arun Basil Lal * @refer https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_handle_upload_prefilter */ function prefix_convert_filename_to_lowercase( $file ) { $image_extensions =…

Log WordPress Database Queries To File

Log WordPress Database Queries To File

By OutsourcedContent — on August 2, 2021 Useful to see what changes are made in the WordPress database by a plugin, theme or other code. /** * Log database queries to the /wp-content/sql.log file. * * @link https://wordpress.stackexchange.com/a/144353/90061 */ add_filter( ‘query’, function( $query ){ // Filter out everything that shouldn’t be logged. if…

How to Check if The Current User is The Post Author in WordPress

How to Check if The Current User is The Post Author in WordPress

While working on a WooCommerce project recently, my client asked me if there is a way to show a message to seller on their own product items. A simple message like “you are the seller of this item” if the product page is previewed by the seller itself. Typically WooCommerce is a plugin which essentially…

Prevent User Registration in WordPress From Specific Domain

Prevent User Registration in WordPress From Specific Domain

Usually it’s a good idea to disable user registration in WordPress, if you do not use membership feature, since spammers can attack your website with spam user registrations. One of my clients had enabled the option “anyone can register” in WordPress settings and allowed visitors to register. Within as week, he received couple of user…

How to Disable Emojicons Feature Introduced in New Wordpress 4.2

How to Disable Emojicons Feature Introduced in New Wordpress 4.2

With the release of new WordPress 4.2 version, WordPress team introduced the use of Emojicons in your posts and comments. In order to make this new Emojicons feature to work, WordPress automatically adds JavaScript libraries in your page. Although it’s a nice feature to have for some bloggers who use Emojicons very frequently, but for…

How to Allow Users to Login With Email Address in WordPress

How to Allow Users to Login With Email Address in WordPress

WordPress by default assign a unique username to each user on registration. As usernames are unique on a WordPress website, there is a fine possibility that the username a user wants to register has already been taken by another user, in that case, he have to choose a different username that user might not remember…

How to Change WordPress Email Content Type to HTML Instead of Text

How to Change WordPress Email Content Type to HTML Instead of Text

WordPress uses wp_mail function to send all emails and the default content type for these emails is text/plain. It simply means that all emails, goes through WordPress, will be sent in text format only and WordPress will not allow any HTML to be placed in your emails. But on a project, you may require to…