WordPress adds slashes before quotes even if we do not want to use magic quotes. To solve this problem, you can use either of the following two functions on the values returned from POST requests- wp_unslash stripslashes_deep References: https://developer.wordpress.org/reference/functions/wp_unslash/ https://developer.wordpress.org/reference/functions/stripslashes_deep/ https://core.trac.wordpress.org/ticket/18322
WordPress: Missing canonical tags on archive pages
WordPress keeps surprising me even after more than a decade since I started using it. Today I came to know that WordPress only generates canonical tags for singular pages (posts & pages). WordPress does not add canonical tags to archive pages including author page, post type archives, taxonomy archives etc. So, how to add canonical…
404 pages getting redirected to home
Today, I wasted major part of my day trying to figure out why my subfolder based WordPress multisite install is redirecting all 404 errors to the site’s home page. The problem turned out to be the constant “NOBLOGREDIRECT” which I defined in wp-config.php file. This constant ensures that in a multisite install, if anyone tries…
Prevent Memory Leak in WordPress
Recently I faced an issue of memory leak in one of my WordPress projects. I was running a function that was reading post meta and user metadata of thousands of objects. I thought reading data from MySQL is cheap in terms of processing power and memory, but it turned out it was causing my function…
Correct Way to Manage Title Tags in WordPress
Correct way to add or modify title tags in WordPress using the latest theme support feature and the filter hook to dynamically modify it on the fly.
How to change Post Type in WordPress
Use these simple methods to easily change post type of single or multiple posts while working with multiple post types in WordPress.
How to count words in Unicode string using PHP
How to count words in Unicode string using PHP? This sounds too easy. After all, PHP has so many string manipulation functions. To count words, we can simply use str_word_count and we are good to go. But there is a problem. While this function works fine for English strings, developers find this function unpredictable as sometimes…