Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Category: Wordpress

Wordpress

WordPress: Use REST API to Build Headless WordPress Applications

- 30.03.26 - ErcanOPAK comment on WordPress: Use REST API to Build Headless WordPress Applications

πŸš€ WordPress as Content API WordPress theme limiting you? Build React/Vue frontend, use WordPress as content source. REST API turns WordPress into headless CMS. Built-in Endpoints # All built-in, no setup needed! # Get all posts GET https://yoursite.com/wp-json/wp/v2/posts # Get single post GET https://yoursite.com/wp-json/wp/v2/posts/123 # Get pages GET https://yoursite.com/wp-json/wp/v2/pages # Get categories GET https://yoursite.com/wp-json/wp/v2/categories # […]

Read More
Wordpress

WordPress: Use WP-CLI for Command-Line Site Management

- 30.03.26 - ErcanOPAK comment on WordPress: Use WP-CLI for Command-Line Site Management

⚑ Manage WordPress from Terminal Clicking through admin for every site update? Slow. WP-CLI lets you install plugins, update core, manage usersβ€”all from command line. 10x faster. Install WP-CLI # Download curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar # Make executable chmod +x wp-cli.phar # Move to PATH sudo mv wp-cli.phar /usr/local/bin/wp # Test wp –info πŸš€ Essential Commands […]

Read More
Wordpress

WordPress: Enable Object Caching with Redis for 10x Performance

- 22.03.26 - ErcanOPAK comment on WordPress: Enable Object Caching with Redis for 10x Performance

πŸš€ Database Queries: 100 β†’ 5 Every page load = 100 database queries. Redis caches them in memory. Page generation: 800ms β†’ 80ms. What Is Object Caching? WordPress queries database repeatedly for same data (user info, settings, post meta). Object cache stores results in RAM for instant retrieval. πŸ”„ Without Object Cache Page Load Request: […]

Read More
Wordpress

WordPress: Create Custom Post Types for Portfolios, Products, Reviews

- 22.03.26 - ErcanOPAK comment on WordPress: Create Custom Post Types for Portfolios, Products, Reviews

πŸ“¦ Beyond Posts and Pages WordPress has Posts and Pages. You need Portfolios, Products, Team Members? Custom Post Types unlock unlimited content structures. What Are Custom Post Types? Think of them as custom content containers with their own admin interface, taxonomies, and templates. πŸ’‘ Use Cases Portfolio: Projects with client, year, category Products: E-commerce items […]

Read More
Wordpress

WordPress Transients: Cache Data Without a Plugin

- 19.03.26 - ErcanOPAK comment on WordPress Transients: Cache Data Without a Plugin

⚑ Built-in Caching System API call taking 2 seconds? Database query slow? Cache it with Transients API. No plugin needed. Basic Usage // Get from cache $data = get_transient(‘my_cached_data’); // Not in cache? Get fresh data if (false === $data) { $data = expensive_api_call(); // Store for 1 hour (3600 seconds) set_transient(‘my_cached_data’, $data, HOUR_IN_SECONDS); } […]

Read More
Wordpress

WordPress Query Monitor: Debug Performance Issues in Real Time

- 19.03.26 - ErcanOPAK comment on WordPress Query Monitor: Debug Performance Issues in Real Time

πŸ” X-Ray Vision for WordPress Site slow? Don’t know why? Query Monitor shows every database query, hook, HTTP request in real time. Install: Plugins β†’ Add New β†’ Query Monitor β†’ Free, 100K+ active installs What It Shows βœ… Database Queries: Slow queries highlighted, execution time, duplicate queries βœ… PHP Errors: Notices, warnings, fatal errors […]

Read More
Wordpress

WordPress: Use Autoptimize to Minify CSS/JS Without Coding

- 19.03.26 | 19.03.26 - ErcanOPAK comment on WordPress: Use Autoptimize to Minify CSS/JS Without Coding

PageSpeed says ‘Minify CSS/JS’. You don’t know how. Hire developer? $500. Autoptimize Plugin: Free, automatic minification. Install: Plugins β†’ Add New β†’ Autoptimize β†’ Install Settings: βœ“ Optimize JavaScript βœ“ Optimize CSS βœ“ Optimize HTML βœ“ Aggregate inline JS/CSS Result: CSS/JS files combined & minified. PageSpeed score +20 points. Advanced: Enable Critical CSS for above-fold […]

Read More
Wordpress

WordPress: Disable Pingbacks to Stop Comment Spam

- 19.03.26 | 19.03.26 - ErcanOPAK comment on WordPress: Disable Pingbacks to Stop Comment Spam

Getting 500 spam comments daily? Most are pingback spam from scrapers. Disable Pingbacks: // functions.php add_filter(‘wp_headers’, function($headers) { unset($headers[‘X-Pingback’]); return $headers; }); add_filter(‘xmlrpc_enabled’, ‘__return_false’); add_filter(‘wp_xmlrpc_server_class’, ‘__return_false’); Settings: Settings β†’ Discussion β†’ Uncheck ‘Allow link notifications from other blogs’ Result: 90% less spam. No legitimate functionality lost.

Read More
Wordpress

WordPress: Disable REST API to Block 90% of Attack Vectors

- 19.03.26 - ErcanOPAK comment on WordPress: Disable REST API to Block 90% of Attack Vectors

πŸ”’ Close the Security Hole Most WordPress hacks exploit REST API endpoints. Don’t need headless? Disable it. // Disable REST API for non-logged users add_filter(‘rest_authentication_errors’, function($result) { if (!is_user_logged_in()) { return new WP_Error( ‘rest_disabled’, ‘REST API disabled’, array(‘status’ => 401) ); } return $result; }); What This Blocks: Automated user enumeration, content scraping, brute force […]

Read More
Wordpress

WordPress: Use WP-CLI to Manage 100 Sites in 10 Minutes

- 19.03.26 - ErcanOPAK comment on WordPress: Use WP-CLI to Manage 100 Sites in 10 Minutes

⚑ Command Line Superpower Updating plugins via admin? 2 minutes per site Γ— 100 sites = 3+ hours. WP-CLI? 10 minutes total. # Update all plugins on all sites wp plugin update –all # Search & replace URLs after migration wp search-replace ‘oldsite.com’ ‘newsite.com’ # Create users in bulk wp user create john john@example.com –role=editor […]

Read More
Wordpress

WordPress: Finding the Plugin That’s Slowing You Down

- 01.03.26 - ErcanOPAK comment on WordPress: Finding the Plugin That’s Slowing You Down

Is your admin dashboard crawling? You don’t need a new host; you need the Query Monitor plugin. What it exposes: Database queries triggered by each plugin. Slow API calls to external services. PHP errors and warnings hidden in the background. Once installed, look at the top bar. It will turn red if a query takes […]

Read More
Wordpress

WordPress: Stop Developing on Live Servers! Use LocalWP

- 01.03.26 - ErcanOPAK comment on WordPress: Stop Developing on Live Servers! Use LocalWP

⚠️ Live Editing is Dangerous Breaking your site while customers are browsing is a nightmare. LocalWP creates a perfect mirror of your site on your PC. Feature Benefit Live Links Share your local site with clients over the internet. One-Click SSL Test HTTPS without complicated setups. Blueprints Save your favorite plugin/theme combos as a template.

Read More
Wordpress

WordPress: Fixing the ‘Slow wp_options’ Query with Custom Indexing

- 01.03.26 - ErcanOPAK comment on WordPress: Fixing the ‘Slow wp_options’ Query with Custom Indexing

In massive sites, the wp_options table becomes a bottleneck because autoload columns aren’t always indexed efficiently. The Fix: Running this SQL command can shave milliseconds off every single page load by helping MySQL find autoloaded options faster: CREATE INDEX autoloadindex ON wp_options (autoload, option_name); This is a low-level optimization that even ‘Premium’ caching plugins often […]

Read More
Wordpress

WordPress: Transitioning to Headless Architecture with REST API

- 01.03.26 - ErcanOPAK comment on WordPress: Transitioning to Headless Architecture with REST API

WordPress isn’t just a blog; it’s a powerful Content API. You can use it as a backend for React or Next.js apps. // Add custom field to REST API response add_action(‘rest_api_init’, function () { register_rest_field(‘post’, ‘reading_time’, [ ‘get_callback’ => function($post_array) { return calculate_reading_time($post_array[‘content’][‘rendered’]); } ]); }); This allows you to leverage WP’s amazing admin interface […]

Read More
Wordpress

WordPress: Massive Site Migrations via WP-CLI (Terminal Power)

- 01.03.26 - ErcanOPAK comment on WordPress: Massive Site Migrations via WP-CLI (Terminal Power)

Why use the dashboard for bulk actions? Professionals use WP-CLI. It’s faster, safer, and bypasses PHP execution time limits. # Replace all URLs after moving to a new domain wp search-replace ‘old-domain.com’ ‘new-domain.com’ –skip-columns=guid # Regenerate all thumbnails in one go wp media regenerate –yes This is the essential tool for any developer managing more […]

Read More
Wordpress

WordPress: Scaling to Millions of Hits with Persistent Object Caching

- 01.03.26 - ErcanOPAK comment on WordPress: Scaling to Millions of Hits with Persistent Object Caching

Even with page caching (like WP Rocket), your database can still crawl. Persistent Object Caching stores the results of complex SQL queries in RAM using Redis. // Verify if Object Cache is active $cache_info = wp_cache_get(‘my_complex_query_result’); if ( false === $cache_info ) { $cache_info = $wpdb->get_results(“SELECT… LARGE QUERY”); wp_cache_set(‘my_complex_query_result’, $cache_info, ”, 3600); } This reduces […]

Read More
Wordpress

WordPress: Hardening Cookies by Changing Your Security Salts

- 28.02.26 - ErcanOPAK comment on WordPress: Hardening Cookies by Changing Your Security Salts

If your site has ever been compromised, or you just want a security boost, you must change your Authentication Salts. Salts add extra randomness to your passwords. Changing them in wp-config.php will instantly log out every user and invalidate all current sessions. It’s like changing the locks on your house doors. Note: Get fresh keys […]

Read More
Wordpress

WordPress: Dequeueing Unused CSS/JS from Plugins to Improve LCP

- 28.02.26 - ErcanOPAK comment on WordPress: Dequeueing Unused CSS/JS from Plugins to Improve LCP

Many plugins (like Contact Form 7) load their scripts on every page, even if there’s no form. This destroys your Google PageSpeed score. add_action(‘wp_print_scripts’, ‘remove_unused_scripts’, 100); function remove_unused_scripts() { if (!is_page(‘contact’)) { wp_dequeue_script(‘contact-form-7’); wp_dequeue_style(‘contact-form-7′); } } Result: Your homepage loads 200KB less data, leading to a much faster ‘Largest Contentful Paint’ (LCP).

Read More
Wordpress

WordPress: Creating Professional Custom Post Types Without Plugins

- 28.02.26 - ErcanOPAK comment on WordPress: Creating Professional Custom Post Types Without Plugins

Plugins like CPT UI are great, but adding code to functions.php is cleaner and faster. It prevents unnecessary database queries. register_post_type(‘portfolio’, array( ‘labels’ => array(‘name’ => ‘Portfolios’), ‘public’ => true, ‘has_archive’ => true, ‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’), ‘menu_icon’ => ‘dashicons-portfolio’ )); Why? Native code is easier to version control and doesn’t break during plugin […]

Read More
Wordpress

WordPress: Controlling the Heartbeat API to Save Server CPU

- 28.02.26 - ErcanOPAK comment on WordPress: Controlling the Heartbeat API to Save Server CPU

The WordPress Heartbeat API sends AJAX requests every 15-60 seconds to sync data between the browser and server. While useful, it can consume massive CPU on shared hosting. // Reduce Heartbeat frequency add_action( ‘init’, ‘stop_heartbeat’, 1 ); function stop_heartbeat() { wp_deregister_script(‘heartbeat’); } Recommendation: Instead of disabling it entirely, use a plugin like ‘Heartbeat Control’ to […]

Read More
Wordpress

WordPress: Protect Your Site from Brute Force by Disabling XML-RPC

- 28.02.26 - ErcanOPAK comment on WordPress: Protect Your Site from Brute Force by Disabling XML-RPC

XML-RPC is an old API used for remote access. Today, it’s mostly a target for hackers to try thousands of password combinations in a single request. How to Disable: Paste this into your .htaccess file: Order Deny,Allow Deny from all This simple block reduces server load and significantly hardens your security wall.

Read More
Wordpress

WordPress: Instant Speed Boost by Limiting Post Revisions

- 28.02.26 - ErcanOPAK comment on WordPress: Instant Speed Boost by Limiting Post Revisions

By default, WordPress saves every single edit as a revision. For a 500-post blog, your database could be bloated with 5000+ unnecessary rows, slowing down SQL queries. The Solution: Add this line to your wp-config.php to keep only the last 3 versions: define(‘WP_POST_REVISIONS’, 3); This keeps your wp_posts table lean and your server response times […]

Read More
Wordpress

WordPress Caching: The 4-Layer Strategy That Handles 1 Million Daily Visitors

- 23.02.26 - ErcanOPAK comment on WordPress Caching: The 4-Layer Strategy That Handles 1 Million Daily Visitors

πŸš€ From Crash to Cash Your site goes viral. Reddit hug of death. Server crashes. You lose $50,000 in sales. This doesn’t have to happen. The 4-Layer Caching Architecture 🌍 Layer 1: CDN (Cloudflare) What it does: Caches entire pages at edge servers worldwide Hit rate: 80-95% of requests never touch your server Cost: Free […]

Read More
Wordpress

WordPress as a Headless CMS: Why Fortune 500 Companies Are Making The Switch

- 23.02.26 - ErcanOPAK comment on WordPress as a Headless CMS: Why Fortune 500 Companies Are Making The Switch

πŸ’Ό The $10 Billion Problem Traditional WordPress sites can’t handle 100,000 concurrent users. Your marketing team loves WordPress. Your engineering team hates the performance. Sound familiar? The Headless Solution: Best of Both Worlds 🎨 Content Team Gets Familiar WordPress admin Gutenberg editor they know All their favorite plugins No training needed ⚑ Dev Team Gets […]

Read More
Wordpress

WordPress: Use wp_cache API for Object Caching Without Plugin

- 22.02.26 - ErcanOPAK comment on WordPress: Use wp_cache API for Object Caching Without Plugin

Repeated database queries kill performance. wp_cache API provides in-memory object caching natively. Cache Expensive Query: $cache_key = ‘popular_posts’; $posts = wp_cache_get($cache_key); if ($posts === false) { // Cache miss – query database $posts = $wpdb->get_results(“SELECT * FROM wp_posts WHERE …..”); wp_cache_set($cache_key, $posts, ”, 3600); // Cache 1 hour } return $posts; Note: Works with persistent […]

Read More
Wordpress

WordPress: Use Custom Post Statuses Beyond Draft and Published

- 22.02.26 - ErcanOPAK comment on WordPress: Use Custom Post Statuses Beyond Draft and Published

Stuck with just Draft/Published/Scheduled? Register custom post statuses for better editorial workflow. Register Status: register_post_status(‘in_review’, array( ‘label’ => ‘In Review’, ‘public’ => false, ‘show_in_admin_all_list’ => true, ‘show_in_admin_status_list’ => true )); Add to Quick Edit: add_filter(‘display_post_states’, function($states, $post) { if (get_post_status($post->ID) == ‘in_review’) { $states[] = ‘In Review’; } return $states; }, 10, 2); Perfect for […]

Read More
Wordpress

WordPress: Boosting API Performance with the Transients API

- 21.02.26 - ErcanOPAK comment on WordPress: Boosting API Performance with the Transients API

Fetching data from external APIs on every page load is a performance killer. The Transients API allows you to cache that data in the WP database for a specific period. // Store data for 12 hours set_transient(‘external_data_cache’, $api_data, 12 * HOUR_IN_SECONDS); This simple trick can reduce server-side execution time from seconds to milliseconds for data-heavy […]

Read More
Wordpress

WordPress: Transitioning to a Headless CMS with WP-GraphQL

- 21.02.26 - ErcanOPAK comment on WordPress: Transitioning to a Headless CMS with WP-GraphQL

Why settle for a traditional monolith? Many modern enterprises use WordPress as a Headless CMS, serving data to a Next.js or React frontend via GraphQL. query GetPosts { posts { nodes { title excerpt featuredImage { node { sourceUrl } } } } } This approach combines the world-class content management of WordPress with the […]

Read More
Wordpress

WordPress: Identifying Slow Plugins with Query Monitor

- 21.02.26 - ErcanOPAK comment on WordPress: Identifying Slow Plugins with Query Monitor

Is your site slow? Don’t guess. Query Monitor is the professional debugger for WP. It highlights: ❌ Duplicate SQL queries. ⚠️ Slow API requests (external). πŸ”₯ Memory-hungry plugins. Check the ‘Queries by Component’ section to see exactly which plugin is adding 500ms to your load time.

Read More
Wordpress

WordPress: Manage Your Entire Site from the Terminal with WP-CLI

- 21.02.26 - ErcanOPAK comment on WordPress: Manage Your Entire Site from the Terminal with WP-CLI

Why use a slow GUI when you can update 50 plugins in 2 seconds? # Update everything at once wp core update && wp plugin update –all # Regenerate all thumbnails wp media regenerate –yes ⚠️ Warning: Always take a snapshot with wp db export before running bulk commands!

Read More
Page 1 of 5
1 2 3 4 5 Next Β»

Posts navigation

Older posts
April 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Mar    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (859)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (754)
  • Add Constraint to SQL Table to ensure email contains @ (578)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (564)
  • Average of all values in a column that are not zero in SQL (531)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (489)
  • Find numbers with more than two decimal places in SQL (448)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries
  • SQL: Use Window Functions for Advanced Analytical Queries
  • .NET Core: Use Background Services for Long-Running Tasks
  • .NET Core: Use Minimal APIs for Lightweight HTTP Services
  • Git: Use Cherry-Pick to Apply Specific Commits Across Branches
  • Git: Use Interactive Rebase to Clean Up Commit History Before Merge

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (859)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (754)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com