Archives: Tech

Specialized vs. Miscellaneous Blogs

·
Specialized Blog Focus: One niche (e.g., tech, travel). Pros: Builds authority, attracts engaged readers, better SEO, niche monetization. Cons: Limited
  • How to Make ISRC Number and Audio Player URL Custom Fields Visible in the Post List and Editable via Quick Edit

    How to Make ISRC Number and Audio Player URL Custom Fields Visible in the Post List and Editable via Quick Edit

    By adding the following code, you can achieve this functionality.

    // PART 1: Display columns
    // Add custom columns for ISRC and Audio Player URL
    function add_acf_custom_columns($columns) {
        $columns['isrc_number'] = __('ISRC Number');
        $columns['audio_player_url'] = __('Audio Player URL');
        return $columns;
    }
    add_filter('manage_post_posts_columns', 'add_acf_custom_columns');
    
    // Populate the columns with ACF field data
    function display_acf_custom_columns($column, $post_id) {
        switch ($column) {
            case 'isrc_number':
                echo get_field('isrc_number', $post_id);
                break;
            case 'audio_player_url':
                $url = get_field('audio_player_url', $post_id);
                if ($url) {
                    echo '<a href="' . esc_url($url) . '" target="_blank">' . esc_url($url) . '</a>';
                }
                break;
        }
    }
    add_action('manage_posts_custom_column', 'display_acf_custom_columns', 10, 2);
    
    // Make columns sortable
    function make_acf_columns_sortable($columns) {
        $columns['isrc_number'] = 'isrc_number';
        return $columns;
    }
    add_filter('manage_edit-post_sortable_columns', 'make_acf_columns_sortable');
    
    // PART 2: Quick Edit functionality
    // Add quick edit fields
    function add_quick_edit_custom_box($column_name, $post_type) {
        if ($post_type !== 'post') return;
        
        switch($column_name) {
            case 'isrc_number':
                ?>
                <fieldset class="inline-edit-col-right">
                    <div class="inline-edit-col">
                        <label>
                            <span class="title">ISRC</span>
                            <span class="input-text-wrap">
                                <input type="text" name="isrc_number" class="isrc_number">
                            </span>
                        </label>
                    </div>
                </fieldset>
                <?php
                break;
            case 'audio_player_url':
                ?>
                <fieldset class="inline-edit-col-right">
                    <div class="inline-edit-col">
                        <label>
                            <span class="title">Audio URL</span>
                            <span class="input-text-wrap">
                                <input type="url" name="audio_player_url" class="audio_player_url">
                            </span>
                        </label>
                    </div>
                </fieldset>
                <?php
                break;
        }
    }
    add_action('quick_edit_custom_box', 'add_quick_edit_custom_box', 10, 2);
    
    // Save quick edit data
    function save_quick_edit_data($post_id) {
        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
        
        if (isset($_POST['isrc_number'])) {
            update_field('isrc_number', $_POST['isrc_number'], $post_id);
        }
        if (isset($_POST['audio_player_url'])) {
            update_field('audio_player_url', $_POST['audio_player_url'], $post_id);
        }
    }
    add_action('save_post', 'save_quick_edit_data');
    
    // Populate quick edit fields with existing values
    function add_quick_edit_javascript() {
        ?>
        <script type="text/javascript">
        jQuery(document).ready(function($) {
            var wp_inline_edit = inlineEditPost.edit;
            inlineEditPost.edit = function(id) {
                wp_inline_edit.apply(this, arguments);
                var post_id = 0;
                if (typeof(id) == 'object') {
                    post_id = parseInt(this.getId(id));
                }
                
                if (post_id > 0) {
                    var row = $('#post-' + post_id);
                    var isrc = $('.isrc_number', row).text();
                    var audio_url = $('.audio_player_url', row).text();
                    
                    $('#edit-' + post_id + ' input[name="isrc_number"]').val(isrc);
                    $('#edit-' + post_id + ' input[name="audio_player_url"]').val(audio_url);
                }
            };
        });
        </script>
        <?php
    }
    add_action('admin_footer', 'add_quick_edit_javascript');

    It is also possible to display this using the Meta Fields Block plugin even in block-based themes.

    However, pulling the value of Advanced Custom Fields (ACF) into a Download button was not achievable in this setup. While it could be done by customizing the PHP code, implementing it within the constraints of a block-based theme seems to lack some necessary methods or approaches.

    in
  • How to Fix a Website Broken by the WP Code Snippets Plugin

    How to Fix a Website Broken by the WP Code Snippets Plugin

    If your website breaks due to an action such as adding incorrect PHP code in the WP Code Snippets plugin and activating it, you can use the Safe Mode feature to resolve the issue. By enabling snippet safe mode, you can access your site and deactivate the problematic code snippet.

    Steps to Use Safe Mode:

    1. Add the “wpcode-safe-mode” Parameter to the Admin URL
      If your site’s admin URL is as follows:
      https://example.com/wp-admin
      Add the parameter ?wpcode-safe-mode=1 to the URL, like this:
      https://example.com/wp-admin/?wpcode-safe-mode=1
    2. Access Safe Mode
      After navigating to the Safe Mode URL, go to the list of snippets. Locate the problematic snippet and deactivate it.
      This should resolve the issue and restore your site.
    3. Keep Safe Mode Activated if Needed
      Safe Mode remains active until you click the link in the notification to disable it.

    Important Notes:

    • User Permissions: Only users with permissions to activate or deactivate snippets can use Safe Mode.
    • Login Required: You must log in to enable Safe Mode.
      If you are logged out and unable to access your site, you can still use the Safe Mode parameter on the login page. However, the parameter will not work on other pages unless you are logged in.

    By following these steps, you can fix your site while avoiding further complications.

    in
  • How to Enable Multisite in WordPress

    How to Enable Multisite in WordPress
    1. First, add the following code to your wp-config.php file:
       define('WP_ALLOW_MULTISITE', true);
    1. Next, access the admin dashboard and choose between subdirectory or subdomain setups for your multisite.
    2. After that, WordPress will display the code you need to add to your .htaccess and wp-config.php files. Copy and paste the provided code into the respective files as instructed.
    3. Create a child site to test the configuration.

    Troubleshooting

    If you encounter the error “ERR_TOO_MANY_REDIRECTS” when accessing the dashboard of a child site:

    • Go to your .htaccess file.
    • Remove any text other than the code added in step 3.
    • Save the changes.
    in
  • Plugins you should install if you use Japanese with WordPress

    Plugins you should install if you use Japanese with WordPress

    If you are dealing with Japanese, you should install the WP Multibyte Patch plugin.

    in
  • What cache plugins do you recommend?

    What cache plugins do you recommend?

    If I were to use it, I would use W3 Total Cache. I don’t use it now.

    in
  • How to upload an avatar in WordPress

    How to upload an avatar in WordPress

    You can use the Simple Local Avatars plugin.

    in