Posts

How to create dynamic HTML sitemap in WordPress with a shortcode (and exclude post types)

 An HTML sitemap is a simple way to display all your website’s content in one place. It helps visitors and search engines quickly navigate your site’s structure. In this tutorial, we’ll show you how to create a WordPress shortcode that generates an HTML sitemap displaying Pages , Posts , and Custom Post Types (CPTs) – with an option to exclude certain post types you don’t want to display. By the end, you’ll have a clean, dynamic sitemap you can insert anywhere using [html_sitemap exclude=”product,portfolio”] . Here’s an example: Pages - Home - About Us - Contact Blog Posts - How to Build a WordPress Site - Top 10 SEO Tips Products - Product A - Product B Add this code to your theme’s functions.php file or in a custom plugin: // [html_sitemap] shortcode with dynamic exclude option function generate_html_sitemap($atts) { // Parse shortcode attributes $atts = shortcode_atts(array( 'exclude' => '', // Default: no exclusions ), $atts, ...

How to add a GST number field to WooCommerce checkout and order emails

 If you’re running a WooCommerce store in India or working with B2B clients, you may need to collect GST numbers during checkout. In this tutorial, you’ll learn how to add an optional GST number field on the WooCommerce checkout page, save it with the order , and display it in the admin panel as well as in the order confirmation emails . Step 1: Add GST Number Field to Checkout Page Use the following code in your theme functions.php file to add a new optional field for the GST number just below the billing fields. // Add GST Number field to checkout add_action('woocommerce_after_checkout_billing_form', 'add_gst_field_to_checkout'); function add_gst_field_to_checkout($checkout) { echo '<div id="gst_number_field"><h3>' . __('GST Number (Optional)') . '</h3>'; woocommerce_form_field('gst_number', array( 'type' => 'text', 'class' => array(...

How to generate Facebook & Google product XML feed in WooCommerce without a plugin

 If you’re running a WooCommerce store and want to connect your products to Facebook Catalogue or Google Merchant Center , you usually rely on a plugin. However, plugins can add bloat, slow down your website, or offer limited control. This guide shows you how to generate a dynamic XML product feed from WooCommerce without installing any plugin. The feed is fully compatible with Facebook Commerce Manager and Google Shopping , supports both simple and variable products , and includes custom attributes like size, colour, and more.Why Build Your Own Feed? Why build your own feed? No need for extra plugins Full control over structure and attributes Supports all WooCommerce product types Dynamically includes all variation attributes Can be used for Facebook, Google, or any XML-based product platform Step 1: Create the XML feed file Create a new file in your website root directory name it as product-feed-xml.php. Paste the followi...

WordPress custom YouTube feed plugin

 The Custom YouTube Feed plugin allows WordPress site owners to display videos from multiple YouTube channels and individual videos in an attractive grid layout. The plugin features pagination, popup video playback, and automatic caching for improved performance. Key Features Multiple Channel Support : Add videos from multiple YouTube channels Individual Video Support : Include specific videos by URL Responsive Grid Layout : 3-column grid that adapts to screen size Popup Video Player : Lightbox-style playback with Magnific Popup Smart Caching : 24-hour cache to reduce API calls Easy Pagination : Automatic pagination for large video collections Admin Dashboard : Simple interface for managing channels and settings Installation Upload the plugin files to your WordPress plugins directory (/wp-content/plugins/) Activate the plugin through the WordPress admin panel Navigate to Settin...

Fetch data from Google Sheet and show in HTML using PHP

 This documentation explains how to use the provided PHP code to fetch data from Google Sheets and display it in a custom layout using HTML/CSS. Setup Instructions 1. Get Your Google Sheet ID Open your Google Sheet in a web browser Look at the URL in the address bar – it will look like: https://docs.google.com/spreadsheets/d/BmzaSyBzQ0cRTrbf_vxrB75nh8AoV3BtawPiiCQ/edit#gid=0 The long string between /d/ and /edit is your Sheet ID (in this example: BmzaSyBzQ0cRTrbf_vxrB75nh8AoV3BtawPiiCQ) 2. Create a Google API Key Go to the Google Cloud Console Create a new project or select an existing one Navigate to “APIs & Services” > “Library” Search for “Google Sheets API” and enable it Go to “APIs & Services” > “Credentials” Click “Create Credentials” and select “API key” Copy your new API key (Optional) Restrict the API key to only work with the Sheets API for security ...

Disable WordPress Comment System Completely

 Here’s a comprehensive function to completely disable the WordPress comment system: <?php // Completely disable WordPress comments and related functionality function disable_comments_system() { // Disable support for comments and trackbacks in post types foreach (get_post_types() as $post_type) { if (post_type_supports($post_type, 'comments')) { remove_post_type_support($post_type, 'comments'); remove_post_type_support($post_type, 'trackbacks'); } } // Close comments on all existing posts update_option('close_comments_for_old_posts', 1); update_option('close_comments_days_old', 0); update_option('comment_registration', 1); update_option('default_ping_status', 'closed'); update_option('default_comment_status', 'closed'); // Redirect any comment feed requests to homepage add_action('template_redirect', fu...

Block HTtrack or any other web scrapper

 There are several web scrappers tools are available by which your website can be downloaded as static files. The simplest way to block these web scrappers is to add the following blocking bots code in your website .htaccess file. ##Block bad bots RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR] RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR] RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR] RewriteCond %{HTTP_USER_AGENT} ^Custo [OR] RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR] RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR] RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR] RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR] RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR] RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR] RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR] RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR] RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR] RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR] RewriteCond %{HTTP_USER_AGENT} ^GetR...