Skip to content
  • Quick Ref
  • Contact
  • About
wpcanyon.com

wpcanyon.com

Bulk internal linking with a safe one‑insert strategy (code + plugin)

Posted on August 19, 2025August 19, 2025 By Admin No Comments on Bulk internal linking with a safe one‑insert strategy (code + plugin)

Bulk Internal Linking with a Safe One-Insert Strategy (Code + Plugin)

Adding internal links in bulk is a powerful way to boost your WordPress site’s SEO and user navigation. However, inserting multiple links repeatedly can cause content bloat, SEO penalties, or broken layouts. The solution? A safe one-insert strategy that ensures each internal link is added only once per post. This tutorial covers how to implement this strategy with a code snippet and a sample plugin, so you can bulk internal link confidently and safely.

Quick Fix: Bulk Internal Linking One Insert WordPress

  1. Use a code snippet or plugin that inserts internal links only once per post.
  2. Define your keywords and target URLs in a mapping array.
  3. Hook into WordPress content filters to replace the first occurrence of each keyword with a link.
  4. Test on a staging site to ensure no layout or content issues.
  5. Deploy on live site once verified.

Why This Happens

Many bulk internal linking tools or scripts insert links every time a keyword appears, causing:

  • Content cluttered with repeated links.
  • Potential SEO penalties for over-optimization.
  • Broken user experience with excessive or misplaced links.
  • Performance issues if many replacements happen on large posts.

A one-insert strategy ensures each keyword is linked only once per post, maintaining content quality and SEO best practices.

Step-by-Step: Implementing a Safe One-Insert Bulk Internal Linking

1. Define Your Keywords and URLs

function get_internal_link_map() {
    return array(
        'WordPress' ='https://wordpress.org/',
        'WooCommerce' ='https://woocommerce.com/',
        'SEO' ='https://moz.com/beginners-guide-to-seo',
    );
}

2. Create a Function to Replace Only the First Occurrence

function replace_first_occurrence( $search, $replace, $subject ) {
    $pos = stripos( $subject, $search );
    if ( $pos !== false ) {
        return substr_replace( $subject, $replace, $pos, strlen( $search ) );
    }
    return $subject;
}

3. Hook Into the Content Filter to Insert Links

function bulk_internal_link_one_insert( $content ) {
    $link_map = get_internal_link_map();

    foreach ( $link_map as $keyword =$url ) {
        // Prepare the anchor tag
        $link = '<a href="' . esc_url( $url ) . '" title="' . esc_attr( $keyword ) . '">' . esc_html( $keyword ) . '</a>';
        // Replace only the first occurrence of the keyword
        $content = replace_first_occurrence( $keyword, $link, $content );
    }

    return $content;
}
add_filter( 'the_content', 'bulk_internal_link_one_insert' );

4. Testing Your Implementation

  • Place the code in your child theme’s functions.php or a site-specific plugin.
  • View posts containing your keywords to verify only the first occurrence is linked.
  • Check for any broken HTML or layout issues.

Safety Rules for Bulk Internal Linking

  • One insert per keyword per post: Avoid multiple links for the same keyword to prevent SEO penalties.
  • Use exact keyword matches: Prevent partial word replacements that break words.
  • Escape URLs and titles: Use esc_url() and esc_attr() for security.
  • Test on staging: Always test before deploying on live sites.
  • Exclude sensitive content: Avoid inserting links in excerpts, widgets, or custom fields unless intended.

Example Plugin: Bulk Internal Linking One Insert

Below is a minimal plugin you can install to bulk internal link your posts safely with the one-insert strategy.

<?php
/*
Plugin Name: Bulk Internal Linking One Insert
Description: Safely insert internal links for defined keywords only once per post.
Version: 1.0
Author: Your Name
*/

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

function biloi_get_internal_link_map() {
    return array(
        'WordPress'   => 'https://wordpress.org/',
        'WooCommerce' => 'https://woocommerce.com/',
        'SEO'         => 'https://moz.com/beginners-guide-to-seo',
    );
}

function biloi_replace_first_occurrence( $search, $replace, $subject ) {
    $pos = stripos( $subject, $search );
    if ( $pos !== false ) {
        return substr_replace( $subject, $replace, $pos, strlen( $search ) );
    }
    return $subject;
}

function biloi_bulk_internal_link_one_insert( $content ) {
    // Only apply to singular posts and pages
    if ( ! is_singular() ) {
        return $content;
    }

    $link_map = biloi_get_internal_link_map();

    foreach ( $link_map as $keyword => $url ) {
        $link = '<a href="' . esc_url( $url ) . '" title="' . esc_attr( $keyword ) . '">' . esc_html( $keyword ) . '</a>';
        $content = biloi_replace_first_occurrence( $keyword, $link, $content );
    }

    return $content;
}
add_filter( 'the_content', 'biloi_bulk_internal_link_one_insert' );
?>

Save this as bulk-internal-linking-one-insert.php and upload it to your wp-content/plugins/ directory. Activate it from the WordPress admin plugins page.

Works On

/table
Environment Compatibility
Web Servers Apache, Nginx, LiteSpeed
Control Panels cPanel, Plesk, DirectAdmin
WordPress Versions 5.0 and above (tested up to 6.x)
PHP Versions 7.2 and above (recommended 7.4+)
…
Automation & Plugins

WooCommerce: Add ‘Click & Collect’ without a plugin

Posted on August 19, 2025August 19, 2025 By Admin No Comments on WooCommerce: Add ‘Click & Collect’ without a plugin

WooCommerce: Add ‘Click & Collect’ without a plugin

If you want to offer your customers a convenient “Click & Collect” option in WooCommerce without installing extra plugins, this guide will show you how to do it quickly and cleanly. By customizing WooCommerce’s built-in local pickup shipping method, you can create a seamless in-store pickup experience without the overhead of additional plugins.

Quick Fix: Customize Local Pickup for ‘Click & Collect’

  1. Enable the Local Pickup shipping method in WooCommerce settings.
  2. Rename “Local Pickup” to “Click & Collect” via a filter in your theme’s functions.php.
  3. Optionally, add instructions or pickup details on the checkout page.
  4. Test the checkout flow to ensure the option appears and works as expected.

Why This Happens

WooCommerce includes a “Local Pickup” shipping method by default, designed for customers who want to pick up their orders instead of having them shipped. However, the default label and messaging might not suit your branding or customer experience goals. Instead of installing a plugin that adds a new shipping method, you can simply repurpose and rename the existing local pickup option. This approach keeps your site lightweight and maintains compatibility with WooCommerce updates.

Step-by-step: Add ‘Click & Collect’ Without a Plugin

  1. Enable Local Pickup Shipping Method

    Go to WooCommerce > Settings > Shipping. Select your shipping zone or create a new one if needed. Click Add shipping method and choose Local Pickup.

  2. Rename Local Pickup to Click & Collect

    Add the following code snippet to your active theme’s functions.php file or a site-specific plugin:

    add_filter( 'woocommerce_shipping_method_title', 'rename_local_pickup_to_click_collect', 10, 2 );
    function rename_local_pickup_to_click_collect( $title, $method ) {
        if ( 'local_pickup' === $method-id ) {
            $title = 'Click & Collect';
        }
        return $title;
    }
  3. Add Pickup Instructions on Checkout (Optional)

    To provide customers with pickup instructions, add this snippet to display a custom message when “Click & Collect” is selected:

    add_action( 'woocommerce_review_order_after_shipping', 'display_click_and_collect_instructions' );
    function display_click_and_collect_instructions() {
        $chosen_methods = WC()-session-get( 'chosen_shipping_methods' );
        if ( ! empty( $chosen_methods ) && in_array( 'local_pickup', $chosen_methods ) ) {
            echo '<div class="woocommerce-info">Please collect your order from our store during business hours.</div>';
        }
    }
  4. Test Your Checkout

    Visit your store’s checkout page, add a product to the cart, and select the “Click & Collect” shipping option. Confirm the label change and that the instructions appear if you added them.

UX Tips for ‘Click & Collect’

  • Clear Pickup Location: Include your store address and opening hours in the instructions or confirmation emails.
  • Order Ready Notification: Consider adding an email or SMS notification to inform customers when their order is ready for pickup.
  • Pickup Time Slots: For advanced setups, you might later integrate a time slot selector, but this requires custom development or plugins.
  • Visual Indicators: Use icons or badges to highlight the “Click & Collect” option at checkout for better visibility.

Works on

Environment Compatibility
Web Servers Apache, Nginx, LiteSpeed
Hosting Panels cPanel, Plesk, Managed WordPress Hosting
WooCommerce Versions WooCommerce 3.0 and above
PHP Versions PHP 7.2 and above

FAQ

  1. Can I add multiple pickup locations without a plugin?

    WooCommerce’s default local pickup method supports only one pickup location per shipping zone. To manage multiple locations, you would need custom code or a plugin.

  2. Will this method affect shipping calculations?

    No. Local Pickup is treated as a shipping method with zero cost by default, so it won’t interfere with shipping rates or taxes unless customized.

  3. How can I change the pickup instructions text?

    Edit the message inside the display_click_and_collect_instructions function in your functions.php file.

  4. Is this solution update-safe?

    Yes. Since it uses WooCommerce’s built-in shipping method and standard filters, it is safe through WooCommerce updates. Just keep your theme or custom plugin updated.

  5. Can I style the pickup instructions?

    Yes. The instructions are wrapped in a div with the woocommerce-info class, which you can target with CSS in your theme.

…
WooCommerce How‑tos

WooCommerce: Disable coupons on sale items only

Posted on August 19, 2025August 19, 2025 By Admin No Comments on WooCommerce: Disable coupons on sale items only

WooCommerce: Disable Coupons on Sale Items Only

If you want to prevent customers from using coupons on products that are already on sale, WooCommerce does not offer a built-in setting for this. The quick fix is to add a custom code snippet that disables coupon usage only when the cart contains sale items. This ensures discounts don’t stack, protecting your margins while still allowing coupons on regular-priced products.

Quick Fix: Disable Coupons on Sale Items with a Filter Snippet

add_filter( 'woocommerce_coupons_enabled', 'disable_coupons_on_sale_items', 10, 2 );
function disable_coupons_on_sale_items( $enabled, $cart ) {
    if ( ! is_admin() && $cart ) {
        foreach ( $cart-get_cart() as $cart_item ) {
            if ( $cart_item['data']-is_on_sale() ) {
                return false; // Disable coupons if any sale item is in the cart
            }
        }
    }
    return $enabled;
}

Why This Happens

WooCommerce’s coupon system applies discounts regardless of whether products are on sale. Many store owners want to avoid stacking discounts because:

  • It reduces profit margins excessively.
  • It can cause confusion with pricing and promotions.
  • It may violate promotional rules or terms.

By default, WooCommerce does not differentiate coupon applicability based on product sale status. The snippet above hooks into the coupon enablement process and disables coupons if any sale item is detected in the cart.

Step-by-Step: How to Disable Coupons on Sale Items Only

  1. Access your theme’s functions.php file or use a code snippets plugin.

    Editing functions.php is common, but using a plugin like “Code Snippets” is safer and easier to manage.

  2. Copy and paste the following code snippet:
add_filter( 'woocommerce_coupons_enabled', 'disable_coupons_on_sale_items', 10, 2 );
function disable_coupons_on_sale_items( $enabled, $cart ) {
    if ( ! is_admin() && $cart ) {
        foreach ( $cart-get_cart() as $cart_item ) {
            if ( $cart_item['data']-is_on_sale() ) {
                return false; // Disable coupons if any sale item is in the cart
            }
        }
    }
    return $enabled;
}
  1. Save the changes.
  2. Clear any caching plugins or server cache.

    This ensures the new code takes effect immediately.

  3. Test the functionality.

    Add a sale item to your cart and try applying a coupon. The coupon should be disabled. Then try with only regular-priced items to confirm coupons still work.

Testing

  1. Add a product on sale to your cart.
  2. Attempt to apply a valid coupon code.

    The coupon should not apply, and WooCommerce will typically show a message that coupons are disabled or invalid.

  3. Remove the sale item and add a regular-priced product.
  4. Apply the same coupon code again.

    This time, the coupon should apply successfully.

  5. Test with multiple items, mixing sale and regular products.

    Coupons should be disabled if any sale item is present.

Works on

Environment Compatibility
Web Servers Apache, Nginx, LiteSpeed
Hosting Panels cPanel, Plesk, DirectAdmin
WooCommerce Versions WooCommerce 3.0 and above (tested on latest versions)
WordPress Versions WordPress 5.0 and above

FAQ

  • Q: Can I disable coupons only on specific sale products?
    A: Yes, you can modify the snippet to check product IDs or categories before disabling coupons.
  • Q: Will this snippet affect admin users or backend coupon testing?
    A: No, the snippet excludes admin area checks, so coupons remain enabled in the backend.
  • Q: What if I want to allow coupons on sale items but limit the discount amount?
    A: You would need a more advanced custom function or a plugin that controls coupon discount rules.
  • Q: Can I combine this with other coupon restrictions?
    A: Yes, but ensure your custom code snippets do not conflict. Test thoroughly after adding multiple restrictions.
  • Q: Is there a plugin that does this without custom code?
    A: Some premium WooCommerce plugins offer advanced coupon restrictions, but the snippet is a lightweight and free solution.
…
WooCommerce How‑tos

WooCommerce Stripe: pending payments stuck — causes & fixes

Posted on August 19, 2025August 19, 2025 By Admin No Comments on WooCommerce Stripe: pending payments stuck — causes & fixes

WooCommerce Stripe: Pending Payments Stuck — Causes & Fixes

If you are using WooCommerce with the Stripe payment gateway, you might encounter an issue where payments remain stuck in a “pending” status indefinitely. This problem prevents orders from completing and can disrupt your store’s sales flow. The quick fix usually involves ensuring that Stripe webhooks are correctly configured and that WooCommerce’s scheduled tasks (cron jobs) are running properly.

Quick Fix: Set Up Stripe Webhooks and Verify WooCommerce Cron

  1. Log in to your Stripe Dashboard.
  2. Navigate to Developers > Webhooks.
  3. Create a new webhook endpoint with your WooCommerce webhook URL:
    https://yourdomain.com/?wc-api=wc_stripe
  4. Select the following events to listen for:
    • payment_intent.succeeded
    • payment_intent.payment_failed
    • charge.refunded
    • charge.failed
    • checkout.session.completed
  5. Save the webhook and copy the signing secret.
  6. Go to WooCommerce > Settings > Payments > Stripe and paste the webhook secret.
  7. Ensure your WordPress cron is running by installing a plugin like WP Crontrol or setting up a real cron job on your server.
  8. Manually trigger WooCommerce scheduled tasks or wait for the next cron run to update payment statuses.

Why This Happens

WooCommerce Stripe payments rely on Stripe’s webhook notifications to update order statuses automatically. When a customer completes payment, Stripe sends an event to your site’s webhook URL. WooCommerce listens for these events and updates the order status accordingly.

If webhooks are missing, misconfigured, or blocked, WooCommerce never receives payment confirmation. As a result, payments stay in a “pending” state. Additionally, if WordPress cron jobs are disabled or not running, scheduled tasks that check payment statuses and update orders won’t execute, causing delays or stuck statuses.

Step-by-Step: Fix WooCommerce Stripe Pending Payments

  1. Verify your webhook URL in Stripe:
    https://yourdomain.com/?wc-api=wc_stripe

    This URL must be publicly accessible and use HTTPS.

  2. Create or update the webhook in Stripe:
    • Log in to Stripe Dashboard > Developers > Webhooks
    • Click Add endpoint
    • Enter the URL above
    • Select these events:
      payment_intent.succeeded
      payment_intent.payment_failed
      charge.refunded
      charge.failed
      checkout.session.completed
    • Save and copy the webhook secret key
  3. Add the webhook secret to WooCommerce:
    1. Go to WordPress Admin > WooCommerce > Settings > Payments > Stripe
    2. Find the Webhook secret field
    3. Paste the copied webhook secret
    4. Save changes
  4. Ensure WordPress cron is running:
    • Install the WP Crontrol plugin
    • Go to Tools > Cron Events and check for WooCommerce scheduled tasks like woocommerce_scheduled_subscription_payment or woocommerce_cancel_unpaid_orders
    • If cron is disabled, enable it by editing wp-config.php and removing or setting define('DISABLE_WP_CRON', false);
    • Alternatively, set up a real server cron job to call wp-cron.php every 5-10 minutes:
    * * * * * wget -q -O - https://yourdomain.com/wp-cron.php?doing_wp_cron /dev/null 2&1
  5. Manually trigger webhook events or wait for cron:
    • In Stripe Dashboard, you can resend webhook events to test
    • Wait for WordPress cron to run and update order statuses
    • Check WooCommerce orders to confirm payment status updates

Checking Logs for Troubleshooting

Logs help identify webhook delivery issues or errors in payment processing.

  • Stripe Logs: In Stripe Dashboard, go to Developers > Logs to see webhook delivery status and errors.
  • WooCommerce Logs: Go to WooCommerce > Status > Logs, select the Stripe log file (e.g., stripe-YYYY-MM-DD.log), and review recent entries.
  • Server Logs: Check your web server error logs for any 4xx or 5xx errors related to the webhook URL.

Works on

Environment Notes
Apache Ensure mod_rewrite is enabled and .htaccess rules allow webhook URL access.
Nginx Configure location blocks to allow access to ?wc-api=wc_stripe endpoint.
LiteSpeed Compatible with Apache .htaccess; verify rewrite rules.
cPanel / Plesk Supports cron jobs and SSL setup needed for webhooks.
Managed WordPress Hosting Check with host if WP cron is disabled and request real cron setup.

FAQ

Q: How do I know if Stripe webhooks are working?
A: Check the Stripe Dashboard under Developers > Webhooks for recent delivery attempts and their status. Successful deliveries show a green checkmark.
…
WooCommerce How‑tos

WooCommerce: Create tiered shipping by product category

Posted on August 19, 2025August 19, 2025 By Admin No Comments on WooCommerce: Create tiered shipping by product category

WooCommerce: Create Tiered Shipping by Product Category

If you run a WooCommerce store, you might want to charge different shipping rates based on product categories. For example, electronics might have a different shipping cost than clothing, or you might want to offer tiered shipping rates depending on the category and order quantity. WooCommerce doesn’t provide tiered shipping by category out of the box, but with a few simple steps, you can set this up quickly.

Quick Fix: Use Shipping Classes and Shipping Zones with Rules

  1. Create shipping classes corresponding to your product categories.
  2. Assign these shipping classes to products in each category.
  3. Set up shipping zones and add flat rate shipping methods.
  4. Configure tiered shipping costs per shipping class using cost formulas.

This approach leverages WooCommerce’s built-in shipping classes and flat rate shipping method cost formulas to simulate tiered shipping by product category without custom coding.

Why This Happens

WooCommerce’s default shipping system calculates shipping costs based on shipping zones and methods. Shipping classes allow grouping products for shipping cost differentiation, but WooCommerce does not natively support tiered or quantity-based shipping rates by category. By assigning shipping classes that mirror categories and using cost formulas, you can create tiered shipping rates that vary by category and quantity.

This method works because the flat rate shipping method supports cost formulas using placeholders like [qty] (quantity of items) and [cost] (base cost). By combining these with shipping classes, you can create tiered costs per category.

Step-by-step: Create Tiered Shipping by Product Category

  1. Create Shipping Classes
    • Go to WooCommerce > Settings > Shipping > Shipping classes.
    • Click Add shipping class for each product category you want to tier. For example:
      • Electronics
      • Clothing
      • Books
    • Save shipping classes.
  2. Assign Shipping Classes to Products
    • Go to Products > All Products.
    • Edit each product and assign the appropriate shipping class under the Shipping tab.
    • Update products.
  3. Set Up Shipping Zones
    • Go to WooCommerce > Settings > Shipping > Shipping zones.
    • Create or edit a shipping zone that applies to your customers (e.g., United States).
    • Add a Flat rate shipping method to this zone.
  4. Configure Tiered Shipping Costs Per Shipping Class
    • Click Edit on the flat rate shipping method.
    • Set the Cost field for the base rate (e.g., 5 for $5 base shipping).
    • Expand the Shipping class costs section.
    • For each shipping class, enter a cost formula that applies tiered rates. For example:
      • Electronics: 10 + ([qty] - 1) * 3 (first item $10, each additional $3)
      • Clothing: 5 + ([qty] - 1) * 1.5 (first item $5, each additional $1.50)
      • Books: 3 + ([qty] - 1) * 1 (first item $3, each additional $1)
    • Save changes.
  5. Test Your Setup
    • Add products from different categories to your cart.
    • Verify the shipping cost updates according to your tiered rules.

Edge Cases and Additional Tips

  • Multiple Categories per Product: WooCommerce shipping classes are single-select, so if a product belongs to multiple categories, assign the shipping class that best fits your shipping cost strategy.
  • Combining Shipping Classes: WooCommerce sums shipping class costs by default, so if your cart contains multiple classes, the total shipping cost will be the sum of each class’s tiered cost.
  • Free Shipping Thresholds: To offer free shipping for certain categories or order totals, add a Free shipping method to your shipping zone with conditions.
  • Using Plugins: For more complex tiered shipping rules (e.g., weight, volume, or mixed conditions), consider plugins like Table Rate Shipping or Advanced Shipping Packages.

Works On

Environment Compatibility
Web Servers Apache, Nginx, LiteSpeed
Control Panels cPanel, Plesk, DirectAdmin
WooCommerce Versions WooCommerce 3.0 and above
WordPress Versions WordPress 5.0 and above

FAQ

  1. Can I set different tiered shipping rates for multiple categories in one order?

    Yes. WooCommerce sums the shipping costs for each shipping class in the cart, so tiered rates per category will combine automatically.

  2. What if a product belongs to multiple categories?

    Since shipping classes are single-select, assign the shipping class that best matches the shipping cost. For complex cases, consider plugins that support multiple shipping classes or custom rules.

  3. Can I use weight or dimensions in tiered shipping calculations?

    Not with the default flat rate method. For weight or dimension-based tiered shipping, use advanced shipping plugins like Table Rate Shipping.

…
WooCommerce How‑tos

WooCommerce: Force NZD & hide other currencies

Posted on August 19, 2025August 19, 2025 By Admin No Comments on WooCommerce: Force NZD & hide other currencies

WooCommerce: Force NZD & Hide Other Currencies

If you run a WooCommerce store and want to restrict all transactions to New Zealand Dollars (NZD) while hiding other currencies from your customers, this guide will help. By default, WooCommerce allows multiple currencies through plugins or custom setups, but sometimes you need to enforce a single currency for consistency in pricing, accounting, or payment processing.

This tutorial shows you how to force NZD as the only currency on your WooCommerce store and hide any other currencies that might be available. The solution involves adding simple code snippets to your theme or a custom plugin, ensuring your store always displays and processes payments in NZD.

Quick Fix: Force NZD & Hide Other Currencies

  1. Add a filter to force WooCommerce currency to NZD.
  2. Remove or disable any multi-currency switchers or plugins.
  3. Optionally, hide currency switcher UI elements if present.
add_filter( 'woocommerce_currency', 'force_woocommerce_currency_to_nzd' );
function force_woocommerce_currency_to_nzd() {
    return 'NZD';
}

This snippet forces WooCommerce to always use NZD as the currency, regardless of user location or any other settings.

Why This Happens

WooCommerce allows currency to be set dynamically, especially when using multi-currency plugins or custom code. These setups can detect user location or preferences and switch currencies accordingly. However, if you want to standardize your store to a single currency (NZD), you need to override this behavior.

Without forcing NZD, customers might see prices in different currencies, which can cause confusion, pricing errors, or payment gateway mismatches. Also, some payment gateways require a consistent currency to function properly.

Step-by-step: Force NZD and Hide Other Currencies

  1. Backup your site. Before making changes, always backup your WordPress files and database.
  2. Access your theme’s functions.php or create a site-specific plugin. You can add the code snippet below to your child theme’s functions.php file or create a custom plugin to keep changes safe from theme updates.
  3. Add the currency filter:
add_filter( 'woocommerce_currency', 'force_woocommerce_currency_to_nzd' );
function force_woocommerce_currency_to_nzd() {
    return 'NZD';
}
  1. Disable multi-currency plugins or features. If you use plugins like WooCommerce Multi-Currency, Currency Switcher, or similar, deactivate or configure them to disable other currencies.
  2. Hide any currency switcher UI elements. If your theme or plugins add currency switchers, remove or hide them via CSS or plugin settings to avoid confusion.
  3. Test your store. Visit your site in incognito mode or different browsers to confirm prices always show in NZD and no other currencies appear.

Payment Gateways

Forcing NZD currency ensures compatibility with payment gateways that require a fixed currency. WooCommerce’s default gateways and popular ones like Stripe and WooPayments support NZD without issues.

If you use Stripe or WooPayments, confirm your Stripe account supports NZD payouts. WooPayments automatically detects the store currency, so forcing NZD avoids currency mismatch errors during checkout.

Works on

  • Web servers: Apache, Nginx, LiteSpeed
  • Hosting panels: cPanel, Plesk, and others
  • WooCommerce versions 4.x and 5.x+
  • Payment gateways: Stripe, WooPayments, PayPal (with NZD support)
  • Compatible with most themes and child themes

FAQ

Q: Will this code affect my multi-currency plugin?
A: Yes. This code overrides WooCommerce’s currency setting globally. You should disable or configure your multi-currency plugin accordingly to avoid conflicts.
Q: Can I force other currencies using the same method?
A: Absolutely. Replace 'NZD' with any valid WooCommerce currency code like 'USD', 'EUR', etc.
Q: What if I want to allow customers to see prices in other currencies but pay in NZD?
This requires a more complex setup with multi-currency plugins that support separate display and payment currencies. The code above forces both display and payment currency to NZD.
Q: Will this affect tax calculations?
No. WooCommerce tax settings remain unchanged. However, ensure your tax rates are configured correctly for NZD pricing.
Q: How do I remove currency switcher widgets from my site?
Check your theme widgets or plugin settings. You can also hide switchers with CSS, for example:
.currency-switcher, .woocommerce-currency-switcher { display: none !important; }
…
WooCommerce How‑tos

WP-Cron not running: setup a real cron on cPanel & Plesk

Posted on August 19, 2025 By Admin No Comments on WP-Cron not running: setup a real cron on cPanel & Plesk

WP-Cron not running: setup a real cron on cPanel & Plesk

WordPress relies on WP-Cron to handle scheduled tasks like publishing scheduled posts, checking for updates, and sending email notifications. However, WP-Cron depends on site traffic to trigger these tasks, which can cause delays or failures on low-traffic sites. The quick fix is to disable WP-Cron’s default behavior and set up a real server cron job via cPanel or Plesk to run WP-Cron reliably.

Quick Fix

  1. Disable WP-Cron’s automatic execution by adding define('DISABLE_WP_CRON', true); to wp-config.php.
  2. Create a cron job in cPanel or Plesk to run the WP-Cron PHP script every 5 or 10 minutes.
  3. Verify the cron job runs successfully and scheduled tasks execute on time.

Why this happens

By default, WP-Cron runs when someone visits your WordPress site. If your site has low or irregular traffic, scheduled tasks may not run on time or at all. This can affect publishing scheduled posts, plugin updates, backups, and other time-sensitive operations. Using a real server cron job ensures WP-Cron runs at fixed intervals regardless of site traffic.

Step-by-step: Setup a real cron on cPanel & Plesk

1. Disable WP-Cron automatic execution

Edit your WordPress wp-config.php file located in the root directory of your WordPress installation. Add the following line above the /* That's all, stop editing! Happy blogging. */ comment:

define('DISABLE_WP_CRON', true);

This prevents WP-Cron from running on every page load.

2. Find the correct PHP executable path

You need to know the path to the PHP binary on your server. Common paths include:

  • /usr/bin/php
  • /usr/local/bin/php
  • /opt/cpanel/ea-php74/root/usr/bin/php (for cPanel with EasyApache 4)

If unsure, contact your hosting provider or run which php via SSH.

3. Create the cron job in cPanel

  1. Log in to your cPanel dashboard.
  2. Navigate to Cron Jobs under the Advanced section.
  3. Under Add New Cron Job, select the interval (e.g., every 5 minutes: */5 * * * *).
  4. In the command field, enter the following command, replacing /path/to/php and /home/username/public_html with your server’s PHP path and WordPress root directory:
/path/to/php /home/username/public_html/wp-cron.php > /dev/null 2>&1

The > /dev/null 2>&1 part discards output to avoid email spam.

  1. Click Add New Cron Job to save.

4. Create the cron job in Plesk

  1. Log in to your Plesk control panel.
  2. Go to Tools & Settings > Scheduled Tasks.
  3. Click Add Task.
  4. Set the task type to Run a command.
  5. Set the schedule (e.g., every 5 minutes).
  6. Enter the command, replacing paths accordingly:
/path/to/php /var/www/vhosts/example.com/httpdocs/wp-cron.php > /dev/null 2>&1
  1. Save the task.

5. Verify the cron job runs

Check your scheduled posts or plugin tasks to confirm they execute on time. You can also check cron logs or enable debugging in WordPress to monitor WP-Cron activity.

Works on

Environment Supported
cPanel (with EasyApache 4) Yes
Plesk Onyx and later Yes
Apache Web Server Yes
Nginx Web Server Yes
LiteSpeed Web Server Yes

FAQ

  • Q: Can I set the cron job to run less frequently than every 5 minutes?

    A: Yes, you can adjust the interval to every 10, 15, or 30 minutes depending on your needs. However, running every 5 minutes is recommended for timely task execution.

  • Q: What if I don’t have SSH access to find the PHP path?

    A: Contact your hosting provider for the correct PHP binary path or check your hosting documentation. Many hosts provide this information in the control panel.

  • Q: Will disabling WP-Cron affect my site negatively?

    A: No, disabling WP-Cron’s automatic execution only stops it from running on page loads. The real cron job you set up will run WP-Cron reliably instead.

  • Q: How do I troubleshoot if the cron job doesn’t seem to run?

    A: Check the cron job logs, verify PHP path and permissions, and ensure the command syntax is correct. Also, confirm DISABLE_WP_CRON is set properly in wp-config.php.

  • Q: Can I use a plugin to manage WP-Cron instead?

    A: Some plugins help monitor or trigger WP-Cron, but they still rely on traffic or server cron jobs. Setting up a real cron job is the most reliable method.

…
Automation

cURL error 60: SSL certificate problem in WordPress

Posted on August 19, 2025August 19, 2025 By Admin No Comments on cURL error 60: SSL certificate problem in WordPress

cURL error 60: SSL certificate problem in WordPress

If you encounter cURL error 60 in WordPress, it means your site is having trouble verifying the SSL certificate of a remote server. This error commonly appears when WordPress tries to communicate with external APIs or update services over HTTPS. The quick fix involves updating the CA certificates on your server or configuring WordPress to bypass strict SSL verification.

Quick Fix

  1. Download the latest cacert.pem file from the official cURL website.
  2. Upload the cacert.pem file to your server, preferably in a secure directory.
  3. Edit your php.ini file to point to the new CA bundle by adding or updating curl.cainfo and openssl.cafile directives.
  4. Restart your web server or PHP-FPM service to apply changes.
  5. Test your WordPress site again to confirm the error is resolved.

Why this happens

The cURL error 60 occurs because cURL, the library WordPress uses for HTTP requests, cannot verify the SSL certificate of the remote server. This usually happens when the CA (Certificate Authority) bundle on your server is outdated or missing. Without a valid CA bundle, cURL cannot confirm the authenticity of the SSL certificate, leading to the error.

Common scenarios include:

  • Outdated or missing CA certificates on your server.
  • Custom PHP installations without proper SSL configuration.
  • WordPress running on local or development environments with self-signed certificates.
  • Firewall or proxy servers interfering with SSL verification.

Step-by-step

1. Download the latest CA certificate bundle

Get the latest cacert.pem file from the official cURL website:

wget https://curl.se/ca/cacert.pem -O /path/to/your/cacert.pem

2. Upload the CA bundle to your server

Place the cacert.pem file in a secure directory on your server, for example:

/etc/ssl/certs/cacert.pem

3. Configure PHP to use the new CA bundle

Edit your php.ini file. The location of this file depends on your server setup. Common locations include /etc/php/7.x/apache2/php.ini or /etc/php/7.x/fpm/php.ini.

Add or update these lines:


curl.cainfo = "/etc/ssl/certs/cacert.pem"
openssl.cafile = "/etc/ssl/certs/cacert.pem"

4. Restart your web server or PHP service

Apply the changes by restarting your web server or PHP-FPM:

# For Apache
sudo systemctl restart apache2

# For Nginx with PHP-FPM
sudo systemctl restart php7.x-fpm
sudo systemctl restart nginx

5. Verify the fix in WordPress

Try performing the action that caused the error, such as updating plugins or themes, or connecting to an external API. The cURL error 60 should no longer appear.

Works on

Environment Notes
Apache Works by updating PHP’s php.ini and restarting Apache
Nginx + PHP-FPM Requires restarting PHP-FPM and Nginx after updating php.ini
LiteSpeed Update php.ini and restart LiteSpeed service
cPanel / Plesk Use the control panel’s PHP configuration editor or edit php.ini manually

FAQ

Q: Can I disable SSL verification to fix cURL error 60?
A: Disabling SSL verification is not recommended as it compromises security. Only use this as a temporary workaround in development environments.
Q: How do I find the location of my php.ini file?
A: Create a PHP file with <?php phpinfo(); ?> and access it via browser. Look for “Loaded Configuration File” to find the path.
Q: What if I don’t have access to php.ini?
A: Contact your hosting provider to update the CA certificates or configure PHP settings for you.
Q: Does this fix work for self-signed certificates?
A: No. Self-signed certificates require adding the certificate to your trusted CA bundle or disabling verification (not recommended).
Q: Will updating WordPress or plugins fix this error?
A: Not usually. This error is related to server configuration, not WordPress core or plugins.
…
Fixes & Errors

Fix ‘The link you followed has expired’ (WordPress uploads)

Posted on August 19, 2025August 19, 2025 By Admin No Comments on Fix ‘The link you followed has expired’ (WordPress uploads)

Fix ‘The link you followed has expired’ (WordPress uploads)

If you encounter the error message “The link you followed has expired” when uploading media or themes in WordPress, it usually means your server’s PHP settings are too low to handle the upload. This guide provides a quick fix to resolve this issue by increasing the PHP limits that control upload size and script execution time.

Quick Fix

  1. Increase the upload_max_filesize and post_max_size values in your PHP configuration.
  2. Increase the max_execution_time and max_input_time values to allow longer script processing.
  3. Restart your web server or PHP service to apply changes.

Why this happens

This error occurs because WordPress relies on PHP settings to manage file uploads and script execution. When you upload a file that exceeds the limits set by upload_max_filesize or post_max_size, or if the upload process takes longer than max_execution_time or max_input_time, PHP stops the process and WordPress shows this error.

Common default PHP limits are often too low for larger media files or themes, especially on shared hosting environments. Adjusting these values allows WordPress to handle bigger uploads and longer processing times.

Step-by-step

1. Locate your PHP configuration file (php.ini)

Find the php.ini file on your server. Its location depends on your hosting environment:

  • On many Linux systems: /etc/php/7.x/apache2/php.ini or /etc/php/7.x/fpm/php.ini
  • On cPanel servers: Use the MultiPHP INI Editor or check public_html/php.ini
  • On local setups: Check your PHP installation folder

2. Edit the php.ini file

Open the php.ini file with a text editor and update or add the following lines:

upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_time = 300
memory_limit = 256M

Explanation:

  • upload_max_filesize: Maximum allowed size for uploaded files.
  • post_max_size: Maximum size of POST data allowed.
  • max_execution_time: Maximum time in seconds a script is allowed to run.
  • max_input_time: Maximum time in seconds a script is allowed to parse input data.
  • memory_limit: Maximum amount of memory a script may consume.

3. Restart your web server or PHP service

After saving the changes, restart your web server or PHP service to apply the new settings.

  • For Apache:
  • sudo systemctl restart apache2
  • For Nginx with PHP-FPM:
  • sudo systemctl restart php7.x-fpm
    sudo systemctl restart nginx

4. Verify changes

Create a phpinfo.php file in your WordPress root directory with the following content:

<?php
phpinfo();
?>

Access it via your browser (e.g., https://yourdomain.com/phpinfo.php) and confirm the new values for upload_max_filesize, post_max_size, max_execution_time, and max_input_time.

5. Remove the phpinfo.php file

For security reasons, delete the phpinfo.php file after verification.

Alternative: Using .htaccess (Apache only)

If you cannot access the php.ini file, you can try adding these lines to your WordPress root .htaccess file:

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
php_value memory_limit 256M

Note: This method only works if your server allows overriding PHP settings via .htaccess. It does not work on Nginx or LiteSpeed servers.

Works on

Server Type Supported Method
Apache (cPanel, Plesk) php.ini, .htaccess
Nginx php.ini (no .htaccess support)
LiteSpeed php.ini (may support .htaccess depending on configuration)
Shared Hosting php.ini (via control panel or MultiPHP INI Editor)

FAQ

Q1: I increased the limits but still get the error. What else can I try?
Check your theme or plugin conflicts by disabling them temporarily. Also, verify your hosting provider does not enforce hard limits beyond your control.
Q2: Can I increase these limits via wp-config.php?
No, PHP upload and execution limits must be set in the server’s PHP configuration or .htaccess (Apache only). wp-config.php cannot modify these settings.
Q3: What if I don’t have access to php.ini or .htaccess?
Contact your hosting provider to increase the PHP limits or use their control panel tools like MultiPHP INI Editor.
Q4: Is it safe to increase these limits?
Yes, but avoid setting excessively high values as they can affect server performance or security. Use reasonable limits based on your needs.
Q5: How do I know the current PHP upload limits?
Create and access a phpinfo.php file with <?php phpinfo(); ?> and look for <
…
Fixes & Errors

WordPress stuck in maintenance mode: how to fix safely

Posted on August 18, 2025August 19, 2025 By Admin No Comments on WordPress stuck in maintenance mode: how to fix safely

WordPress stuck in maintenance mode: how to fix safely

When updating WordPress core, themes, or plugins, you might encounter the dreaded message: “Briefly unavailable for scheduled maintenance. Check back in a minute.” Sometimes, this message never goes away, leaving your site stuck in maintenance mode. The quick fix is to safely delete the .maintenance file from your WordPress root directory. This article explains why this happens and provides a step-by-step guide to resolve it without risking your site.

Quick Fix: Delete the .maintenance file

  1. Access your WordPress site files via FTP, SFTP, or SSH.
  2. Navigate to the root directory of your WordPress installation (where wp-config.php lives).
  3. Locate the file named .maintenance.
  4. Delete the .maintenance file.
  5. Reload your website in the browser; it should now load normally.

Why this happens

WordPress automatically creates a hidden file named .maintenance in the root directory when you start an update process. This file triggers the maintenance mode message to visitors. Normally, WordPress deletes this file once the update completes successfully.

However, if the update process is interrupted — due to server timeout, plugin conflicts, or manual termination — the .maintenance file remains, causing your site to stay in maintenance mode indefinitely.

Because the file is hidden (due to the leading dot), it’s easy to overlook, especially if you’re browsing files with a default file manager that doesn’t show hidden files.

Step-by-step guide to fix and rollback

  1. Backup your site
    Before making any changes, create a full backup of your WordPress files and database. This ensures you can restore your site if anything goes wrong.
  2. Access your site files
    Use an FTP client (like FileZilla), your hosting control panel’s file manager, or SSH to connect to your server.
  3. Locate and delete the .maintenance file
    Navigate to the root WordPress directory. Make sure hidden files are visible. Find and delete the .maintenance file.
  4. Check your site
    Refresh your website in a browser. It should load normally without the maintenance message.
  5. Verify updates
    Login to your WordPress admin dashboard and check if the updates completed successfully. If some updates failed, try updating those plugins/themes again.
  6. Rollback if necessary
    If the update caused issues, use your backup to restore the previous working state. Alternatively, use a plugin like WP Rollback to revert individual plugins or themes.

Deleting .maintenance via SSH

cd /path/to/your/wordpress/root
rm .maintenance

Deleting .maintenance via FTP

  • Connect with your FTP client.
  • Enable viewing hidden files (usually a setting like “Show hidden files”).
  • Navigate to the WordPress root folder.
  • Right-click the .maintenance file and delete it.

Works on

Environment Notes
Apache Standard WordPress hosting; file access via FTP/SSH works the same.
Nginx Same fix applies; no difference in maintenance file handling.
LiteSpeed Compatible; maintenance file method is identical.
cPanel Use File Manager or FTP to delete .maintenance.
Plesk Use File Manager or SSH to remove the file.

FAQ

Q: What if I don’t see the .maintenance file?
A: Ensure your FTP client or file manager shows hidden files. The file starts with a dot and is hidden by default.
Q: Can I just wait for WordPress to exit maintenance mode?
A: Normally yes, but if the update was interrupted, WordPress won’t remove the file automatically, so manual deletion is required.
Q: Is it safe to delete the .maintenance file?
A: Yes, deleting this file only disables maintenance mode. It does not affect your site’s data or files.
Q: How can I prevent this from happening again?
A: Avoid interrupting updates, ensure your server timeout settings are sufficient, and update plugins/themes one at a time if possible.
Q: My site is still broken after deleting .maintenance. What now?
Check for incomplete updates or plugin/theme conflicts. Restore from backup if necessary and try updating components individually.
…
Fixes & Errors

Posts pagination

Previous 1 … 8 9 10 Next

Recent Posts

  • Top WordPress Themes for Blogs in 2025
  • WordPress Admin Panel Trick: Adding ID Field to the Posts Listing
  • Solution previous_posts_link and next_posts_link Not Working
  • Show Top Commentators in WordPress Without a Plugin
  • How to Style Admin Comments in WordPress

Recent Comments

    Archives

    • August 2025

    Categories

    • Admin & Blocks
    • Admin & UI
    • Automation
    • Automation & Plugins
    • Comments
    • Comparisons
    • Database & Revisions
    • Developer Snippets
    • Fixes & Errors
    • Media & Thumbnails
    • Queries & Pagination
    • Security
    • Speed & Security
    • Tips & Tricks
    • WooCommerce How‑tos
    • WordPress Snippets
    • WordPress Themes
    • Terms & Conditions
    • Affiliate Disclosure

    Copyright © 2025 wpcanyon.com.

    Powered by PressBook WordPress theme