Code Snippets by Gaurav Tiwari
Hand-built WordPress, PHP, CSS, JavaScript and dev-tool snippets from 16+ years of building for gauravtiwari.org and client sites. Every one tested on live sites.
- Custom WordPress Login Page — Logo, Background, Colors, URL Title (No Plugin)
Updated on April 24, 2026 - Lock Block Patterns So Clients Can’t Break Them (templateLock, Block Lock, Server-Side Guards)
Updated on April 24, 2026 - Add Your Brand Palette to theme.json Programmatically (PHP Filter)
Updated on April 24, 2026 - Register Custom Block Patterns in WordPress via PHP (2026 Guide)
Updated on April 24, 2026 - Restrict Which Blocks Each User Role Can Use in WordPress (Per-Role, Per-Post-Type)
Updated on April 24, 2026 - Log Every Failed Login Attempt in WordPress (Custom Table + Rotation + Auto-Ban)
Updated on April 24, 2026 - Harden wp-login.php Without a Plugin (Rate Limit, Rename, 2FA, IP Allow-List)
Updated on April 24, 2026 - Clean Up Autoloaded wp_options Bloat (Drop TTFB in One Afternoon)
Updated on April 24, 2026 - Stop wp-cron from Firing on Every Page Load (System Cron in 2026)
Updated on April 24, 2026 - HTML to Etch Converter — Python Script for WordPress Etch Builder
Updated on April 24, 2026 - Kadence Blocks Skills for AI Tools (Free, MIT)
Updated on April 24, 2026 - Bricks Builder Skills for AI Tools (Free, MIT, 35+ Stars)
Updated on April 24, 2026 - GenerateBlocks Skills for AI Tools (Free, MIT, 38 Templates)
Updated on April 24, 2026 - GT Downloads Manager — Free WordPress Plugin for File Tracking
Updated on April 24, 2026 - Minimalistic Cookie Notice for WordPress (under 2KB, no plugin)
Updated on April 24, 2026 - Remove class=”wp-block-heading” From WordPress Heading Blocks
Updated on April 24, 2026 - Product Review Schema Generator (Free, JSON-LD, Rich Snippets Ready)
Updated on April 24, 2026 - Is My Site Down? — Free Real-Time Website Uptime Checker
Updated on April 24, 2026 - Free Domain Lookup Tool — WHOIS, DNS, and Availability in One Click
Updated on April 24, 2026 - Insert AdSense Ads Inside WordPress Loops (Any Position, No Plugin)
Updated on April 24, 2026 - ASP.NET MVC Ajax Redirect (Legacy Pattern + 2026 Alternatives)
Updated on April 24, 2026 - LINQ to SQL: Single Data Context vs Multiple (Legacy Guide + EF Core Notes)
Updated on April 24, 2026 - ROWNUM Simulation in MySQL (Legacy Tricks + ROW_NUMBER() Since MySQL 8)
Updated on April 24, 2026 - Include External JavaScript and CSS in ASP.NET Pages (Webforms + MVC + Razor)
Updated on April 24, 2026 - Render Partial View to String in ASP.NET MVC (Classic + .NET 8/9)
Updated on April 24, 2026 - Customize Read More in Genesis Themes (excerpt_more filter)
Updated on April 24, 2026 - Dynamic Month & Year into Posts (Free WordPress Plugin)
Updated on June 6, 2026 - Remove Spam Links From WordPress Comments (6 snippets that actually work)
Updated on April 24, 2026 - One-Click Webpage Screenshot (Bookmarklet + API Alternatives)
Updated on April 24, 2026 - Manually Ping Your Sitemap to Google (What Still Works in 2026)
Updated on April 24, 2026 - Show Estimated Reading Time in WordPress (1 function, no plugin)
Updated on April 24, 2026 - Inkscape Symbols Library — 24,900+ SVG Symbols, Free Download
Updated on April 24, 2026 - Make the Total WordPress Theme Gutenberg-Compatible (CSS fixes + filters)
Updated on April 24, 2026 - HTML Tools for Mathematics — MathML, MathJax, KaTeX (2026 Stack)
Updated on April 24, 2026
FAQ
How do I use these Code Snippets?
Depending on the code snippet, the usage can differ. Please refer to the individual article/code snippet/plugin for detailed instructions on how to use these.
Do I need to credit you for the code?
No. You can use these codes in your projects, whether personal or commercial. But it would be very kind of you if you could provide credit. That will encourage me to work more and better.
‘This’ code snippet doesn’t work, what to do?
If something doesn’t work, you can report that to me at gaurav@gauravtiwari.org :) I’ll take a maximum of 12 hours to respond to your email.
How to save these code snippets for later?
You can bookmark the pages or save the URLs to getpocket.com — and visit back later. You can also follow me on Twitter to get regular code updates.