Snippets Archive

Codes that are meant to be useful for others. Commercial use of my code strictly prohibited.

How to bring Link Manager back in WordPress

If you choose to create a new database and perform a fresh WordPress install process on your web server, you will notice the installation scripts creates a "wp_links" table on your database ...

Using Auto Draft Posts

There's no doubt that WordPress uses "Autosave" feature for some pretty valid reasons and it is very useful in certain scenario ...

Query WooCommerce Products

There are multiple ways you can query WooCommerce products in WordPress. Though generally you can use the native get_posts function, it is recommended to use the WooCommerce native wc_get_products function ...

Check if WooCommerce is Active

Over the past couple of years, I have written and shared number of snippets on WooCommerce which I hope helped some of you ...

Removing Block Editor Stylesheet

Last year when WordPress 5.0 came out, I wrote a simple post showing how to continue using Classic Editor on your WordPress site ...

Adding Custom Structured Data in WooCommerce

By default WooCommerce adds structured data for every single published product in JSON format. It is a great feature which not only helps the search engines to crawl important information about a product but it also helps with the overall SEO (Search Engine Optimization) strategy of an WooCommerce based eCommerce site ...

Get your Classic WordPress Editor Back

WordPress just released it's latest version (5.0) today which is being widely discussed because some of it's major "improvements" ...

Regex for Twitter Username in PHP

Recently I was working on a project where I had to come up with a solution to validate twitter username before I allow users to insert the data into my database ...

Sanitizing Integer Value with Filter Var

In one of my previous post, I discussed how validate integer variable. However, I recently came across some weird issue while sanitizing an integer ...

Retrieve Simple JSON API Data in PHP

Today I will share a simple PHP script to show how you can retrieve API data using PHP. For demonstration purpose I will use freegeoip ...

Validating Integer in PHP

Every now and then we need to check if the value of a variable is an integer or not. Recently I came across a forum thread where someone is trying to understand why his/her snippet is not giving the appropriate result that he/she is looking for ...

Disable Right Mouse Click for HTML5 Elements

As HTML5 becomes the industry standard markup language for developing web pages, the usage of newly introduced elements are increasing and it will continue (more likely) to grow ...