Tech Tag: WordPress

  • How To Exclude Custom Post Types From WordPress Search Results

    How To Exclude Custom Post Types From WordPress Search Results

    Paste the following code in functions.php to only allow posts and pages.

    function exclude_custom_post_types_from_search($query) {
        if (!is_admin() && $query->is_search) {
            // Specify the post types to include in search results
            $query->set('post_type', array('post', 'page')); // Excludes all other post types
        }
        return $query;
    }
    add_filter('pre_get_posts', 'exclude_custom_post_types_from_search');
    in
  • [Multilingual site] WPML plugin VS Create a site with two domains

    [Multilingual site] WPML plugin VS Create a site with two domains

    WPML Plugin
    Pros:

    • Easy to set up and manage multilingual content from one dashboard.
    • Simplifies updates and maintenance with unified management.
    • Supports multilingual SEO with language-specific URLs.
    • Compatible with most themes and plugins.
    • Cost-effective compared to maintaining separate domains.

    Cons:

    • May impact site performance due to increased database size.
    • Managing translations can grow complex over time.
    • Dependency on plugin updates and support.

    Two Domains Approach
    Pros:

    • Better localization signals for SEO with separate domains.
    • Greater flexibility for branding and market-specific strategies.
    • Potentially better performance without multilingual plugin overhead.

    Cons:

    • Higher costs for domain registration, hosting, and SSL.
    • More effort to manage separate WordPress installations.
    • Risk of duplicate content without proper SEO strategies.

    Conclusion

    • WPML Plugin: Best for centralized, cost-effective management with integrated multilingual features.
    • Two Domains: Ideal for SEO-focused strategies, tailored branding, and market-specific optimization.

    Evaluate your budget, expertise, SEO priorities, and future plans to decide the right approach.

    in
  • Beginner’s Guide to Starting a Super Specialized Blog

    Beginner’s Guide to Starting a Super Specialized Blog

    Starting a super specialized blog can be an exciting venture that allows you to share your passion and knowledge with a targeted audience. This guide will walk you through the essential steps to create a successful niche blog.

    (more…)
    in
  • How to add Breadcrumb NavXT to WordPress

    How to add Breadcrumb NavXT to WordPress

    For a block editor, you add the block. For classic themes, add below code into header.php.

    <?php
    if(function_exists('bcn_display'))
    {
        bcn_display();
    }
    ?>
    in
  • Switching from reCAPTCHA to hCaptcha with Contact Form 7

    Switching from reCAPTCHA to hCaptcha with Contact Form 7

    Starting April 1, 2024, Google’s reCAPTCHA will transition to a paid model, significantly reducing its free usage tier. This change poses challenges for individual users and small website owners who rely on it for spam protection. In response, I decided to switch from reCAPTCHA to hCaptcha for my WordPress contact forms powered by Contact Form 7. Below, I’ll explain why I chose hCaptcha and provide a step-by-step guide to integrating it.


    Why Choose hCaptcha?

    1. Cost-Effectiveness
    • hCaptcha is free to use, even for commercial purposes.
    • It also offers paid plans for those who need advanced features, providing flexibility.
    1. Privacy-Focused
    • Unlike Google’s reCAPTCHA, hCaptcha collects minimal user data and complies with privacy regulations like GDPR and CCPA.
    • This makes it a great choice for privacy-conscious website owners.
    1. Easy Integration with WordPress
    • The dedicated plugin, “hCaptcha for WordPress,” makes it simple to integrate hCaptcha with Contact Form 7 and other WordPress forms.

    How to Integrate hCaptcha with Contact Form 7

    Here’s a step-by-step guide to replacing reCAPTCHA with hCaptcha in Contact Form 7:

    1. Create an hCaptcha Account

    • Visit the official hCaptcha website (https://www.hcaptcha.com) and sign up for an account.
    • Once registered, generate your Site Key and Secret Key:
    • Site Key: Specific to each website you add.
    • Secret Key: Unique to your account.

    2. Install the hCaptcha for WordPress Plugin

    • Log in to your WordPress dashboard.
    • Go to Plugins > Add New and search for “hCaptcha for WordPress.”
    • Install and activate the plugin.

    3. Configure the Plugin

    • Navigate to Settings > hCaptcha in your WordPress admin panel.
    • Enter your Site Key and Secret Key in the respective fields.
    • Under the “Integrations” tab, enable integration with Contact Form 7 by checking the appropriate boxes:
    • Enable “Form Auto-Add” and “Form Embed” to automatically add hCaptcha to your forms.

    4. Verify Functionality

    • Open any Contact Form 7 form on your site and ensure that the hCaptcha widget appears correctly.
    • Test the form submission process to confirm that everything works as expected.

    My Experience After Switching

    After implementing hCaptcha with Contact Form 7, I was pleasantly surprised by how straightforward the setup process was. Most of the work involved configuring the plugin—there was no need for complex coding or manual adjustments in Contact Form 7 itself. Additionally, hCaptcha offers a clean and user-friendly experience that doesn’t disrupt visitors while effectively blocking spam submissions.


    Conclusion

    The transition of Google reCAPTCHA to a paid service has left many website owners searching for alternatives. Fortunately, hCaptcha stands out as an excellent replacement due to its cost-effectiveness, privacy focus, and ease of use. If you’re looking for a reliable spam prevention solution for your WordPress site, I highly recommend giving hCaptcha a try. I’ll continue monitoring its performance on my site and optimize as needed!

    in
  • How to Debug WordPress Errors

    How to Debug WordPress Errors

    To debug errors in WordPress, follow these steps:

    1. Access the wp-config.php File
      Open the wp-config.php file located in the root directory of your WordPress installation.
    2. Enable Debugging
      Find the following line in the file:
       define('WP_DEBUG', false);

    Change it to:

       define('WP_DEBUG', true);
    1. Add Additional Debugging Configurations
      Right below the define('WP_DEBUG', true); line, add the following lines:
       define('WP_DEBUG_LOG', true);
       define('WP_DEBUG_DISPLAY', false);
       error_log('Memory usage: ' . memory_get_usage());
    1. Check the Debug Log
      After these steps, WordPress will log errors to the file located at wp-content/debug.log. This file will continuously grow as errors are logged.
    2. Restore Configurations After Debugging
      Once debugging is complete, revert the wp-config.php settings to their original state to stop the debug log from growing indefinitely:
       define('WP_DEBUG', false);

    This method helps you diagnose WordPress issues while keeping error details logged in a secure place (debug.log), without displaying them publicly on the website.

    in
  • My RSS for a WordPress site is alive, but feedly is saying it is unreachable. Why?

    My RSS for a WordPress site is alive, but feedly is saying it is unreachable. Why?

    If your WordPress RSS feed works but Feedly shows it as unreachable, try these fixes:

    1. Validate the Feed: Use tools like W3C Feed Validator to check for hidden XML errors.
    2. Check Plugins: Deactivate RSS-related plugins to identify conflicts, reactivating them one by one if the issue resolves.
    3. Test the Theme: Switch to a default theme (e.g., Twenty Twenty-Five) to rule out theme-related problems.
    4. Regenerate Permalinks: Go to Settings > Permalinks and save to reset the structure.
    5. Correct Feed URL: Ensure the URL is properly formatted (e.g., ending with /feed/) and test variations.
    6. Clear Cache: Clear WordPress and server-side cache to ensure Feedly fetches fresh data.

    Following these steps can resolve Feedly’s inability to access your feed.

    in
  • How to add download functionality in WordPress?

    How to add download functionality in WordPress?

    I used to use WP Download Manager, but I stopped using it after they raised the price of the paid version. After that, you can use Gutenberg Editor’s “Button” block to place a download button on the “post”, or create a custom post type with the Custom Post Type UI and add a download button there using Gutenberg Editor’s “Button” block.

    in