Archives: Tech

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
  • [Contact Form 7] How to set Recaptcha.js so that it does not load on anything other than the contact page.

    [Contact Form 7] How to set Recaptcha.js so that it does not load on anything other than the contact page.

    I am creating a contact form using Contact Form 7. I use Recaptcha to prevent spam, but because of this, Recaptcha.js always comes up in Pagespeed Insights in “Eliminate render-blocking resources” or in “Reduce unused JavaScript”. Therefore, I researched and implemented a method to prevent Recaptcha.js from loading on pages other than the contact page. Try putting the following code in functions.php.

    function block_recaptcha_badge() {
     if ( !is_page( array( 'contact-me' ) ) ) {
     wp_dequeue_script( 'google-recaptcha' );
     wp_deregister_script( 'google-recaptcha' );
     add_filter( 'wpcf7_load_js', '__return_false' );
     add_filter( 'wpcf7_load_css', '__return_false' );
     }
    }
    add_action( 'wp_print_scripts', 'block_recaptcha_badge' );

    If you have multiple contact form pages, you can increase the array(‘contact-me’ part, like below.

    array( ‘contact-me’, ‘contact-me’, ‘contact-me-3’

    in
  • [Cocoon] Increase site loading speed by lazy loading Adsense

    [Cocoon] Increase site loading speed by lazy loading Adsense

    Today I will show you how to lazy load Adsense to increase site loading speed. First, if you have auto ads turned on, turn them off from the Google Adsense page. After that, go to your own site and paste the following code in the ad code of the ad tab of Cocoon settings, so let’s change that.

    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456"
         crossorigin="anonymous"></script>
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="ca-pub-1234567890123456"
         data-ad-slot="1234567890"
         data-ad-format="auto"
         data-full-width-responsive="true"></ins>
    <script>
         (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

    Delete <script> to </script> from at the top of this and make it look like the following.

    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="ca-pub-1234567890123456"
         data-ad-slot="1234567890"
         data-ad-format="auto"
         data-full-width-responsive="true"></ins>
    <script>
         (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

    Save it.

    Next, go to the access analysis/authentication tab in Cocoon settings, enter the following code in the footer code, and save.

    <script>
    //<![CDATA[
    //lazy load ads
    var lazyloadads = false;
    window.addEventListener("scroll", function() {
        if ((document.documentElement.scrollTop != 0 && lazyloadads === false) || (document.body.scrollTop != 0 && lazyloadads === false)) {
    
            (function() {
                var ad = document.createElement('script');
                ad.type = 'text/javascript';
                ad.async = true;
                ad.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
                var sc = document.getElementsByTagName('script')[0];
                sc.parentNode.insertBefore(ad, sc);
            })();
    
            lazyloadads = true;
        }
    }, true)
    //]]>
    </script>
    in ,
  • [WordPress] Speed up your website

    [WordPress] Speed up your website

    Boost your WordPress site’s speed with these steps:

    • Hosting & Themes: Choose optimized hosting and lightweight themes like Astra.
    • Image Optimization: Compress images with tools like Smush or ShortPixel; use WebP format.
    • Plugins: Keep only essential plugins, update them regularly, and avoid overload.
    • Caching: Use WP Rocket or similar plugins and enable browser caching.
    • Database: Clean junk data and schedule regular maintenance.
    • Code: Minify CSS/JS/HTML with Autoptimize; use plugins for custom code.
    • External Requests: Prefer system fonts and minimize external scripts.
    • Ads: Optimize ads with lazy loading and asynchronous delivery.
    • Extras: Enable GZIP compression, use a CDN, and monitor performance with GTmetrix.

    Fast sites lead to better user experience and higher SEO rankings.

    in
  • Recommendations for WordPress permalink settings

    Recommendations for WordPress permalink settings

    Examples of My Past Mistakes:

    Using the structure “%category%/%postname%” led to issues where only one post would appear if it belonged to multiple categories, and changing a category would alter the permalink.

    Current Recommended Settings:“/post/id/%postname%”This avoids duplication with category pages and can accommodate custom post types.

    Points to Note:

    • Avoid using Japanese URLs.
    • If the title is in Japanese, manually change the permalink to English.

    With this setup, you can manage categories flexibly without negatively impacting SEO.

    in
  • How to import Instagram articles to WordPress

    How to import Instagram articles to WordPress

    I run another site and use a paid plugin called Intagrate Pro. There is also a free Lite version, so you should try using Lite first.

    https://intagrate.io/

    in
  • Problems and solutions that occur when “Force WP User Synchronization” is checked in Simple WordPress Membership

    Problems and solutions that occur when “Force WP User Synchronization” is checked in Simple WordPress Membership

    The following error occurred when I turned on the “Force WP User Sync” setting.

    Error! This site has the force WP user login feature enabled in the settings. We could not find a WP user record for the given username: abcdef

    This error is triggered when a member account doesn’t have a corresponding WP user account. So the plugin fails to log the user into the WP User system.

    Contact the site admin and request them to check your username in the WP Users menu to see what happened with the WP user entry of your account.

    The site admin can disable the Force WP User Synchronization feature in the settings to disable this feature and this error will go away.

    You can use the back button of your browser to go back to the site.

    On the other hand, when this setting was removed, when logging in using the Simple WordPress Membership shortcode,

    [swpm_login_form]

    a problem occurred where the login was not recognized and paid articles could not be viewed.

    Solution

    • Disabled Wordfence Login Security plugin
    • Disabled the “image authentication” setting of the Siteguard plugin

    Now, even if “Force WP User Synchronization” is checked, no errors occur and paid articles can be viewed normally. This shows that Simple WordPress Membership members are stored on a separate system from WP users. Therefore, I understand that the setting to sync with WP users in Advanced Settings is important, and that it is necessary to check “Force WP User Sync.”

    Summary

    If you encounter an issue where you are being treated as if you are logged out even though you’re logged in, first check the “Force WP User Sync” settings. Next, it’s a good idea to verify whether there is a conflict between plugins. In my case, the Wordfence Login Security plugin and the Siteguard plugin were involved.

    While plugins are useful, they can sometimes cause unexpected problems by interfering with each other. It is important to create the optimal operating environment while checking detailed settings and compatibility.

    in
  • Configuration when using WooCommerce and W3 Total Cache together.

    Configuration when using WooCommerce and W3 Total Cache together.

    If you want to use W3 Total Cache but have installed the WooCommerce plugin, I will introduce settings to prevent customer information from being cached.

    (more…)
    in
  • How to increase the font size of bbPress [Memorandum]

    How to increase the font size of bbPress [Memorandum]

    You can increase the font size of bbPress by putting the following code in the additional CSS of the theme.

    bbpress-forums .bbp-topic-content p,
    bbpress-forums .bbp-reply-content p {
        font-size: 18px;
    }
    
    .bbp-forum-title {
        font-size: 22px;
    }
    
    #bbpress-forums .bbp-forum-info .bbp-forum-content, #bbpress-forums p.bbp-topic-meta {
        font-size: 16px;
    }
    
    div#bbpress-forums .bbp-topic-permalink {
        font-size: 20px;
    }
    
    #bbpress-forums ul.bbp-forums, #bbpress-forums ul.bbp-lead-topic, #bbpress-forums ul.bbp-replies, #bbpress-forums ul.bbp-search-results, #bbpress-forums ul.bbp-topics {
        font-size: 18px;
    	LINE-HEIGHT: 1.6em;
    }
    
    .bbp-reply-content {
        font-size: 20px;
    }
    
    div.bbp-breadcrumb, div.bbp-topic-tags {
        font-size: 16px;
    }

    To support Cocoon’s dark mode, add the following CSS.

    #bbpress-forums li{
    	color:#000;
    }
    
    #bbpress-forums a, #bbpress-forums a:hover{
    	color:#608fbd;
    }
    in ,
  • [Cocoon] How to hide the author name of an article

    [Cocoon] How to hide the author name of an article

    Go to Cocoon settings, go to the body tab, scroll down, uncheck Show author name, and save.

    in ,
  • [Cocoon] How to unlink your profile name

    [Cocoon] How to unlink your profile name

    There is a problem where the name in the profile section of Cocoon articles is turned into a link, and I will show you how to remove it. Add the following CSS to Add CSS and save it.

    .author-box .author-name a {
        text-decoration: none;
        color: #333;
        pointer-events:none;
        cursor:default;
    }
    in ,