0

Is there a way in mySQL or otherwise to bulk convert all my tags into lowercase? Thanks!

3

I would highly suggest that you use CSS to do this, as mentioned per other answer. Still, if you need to update the database due to some technical business, here's the way to go.

First, we will try and fetch all the tags using the get_terms() function, then we will update everyone of them using the wp_update_term() function:

<?php
    // Get all the tags
    $tags = get_terms(
        [
            'taxonomy'   => 'post_tag',
            'hide_empty' => FALSE,
        ]
    );

    // Some basic checks
    if ( ! empty( $tags ) && ! is_wp_error( $tags ) ) {

        // Loop through all the tags and convert
        // them to lowercase
        foreach ( $tags as $tag ) {
            // Convert the tag to lowercase
            $lowercase_tag = strtolower( $tag->name );

            // Update the tag
            wp_update_term(
                $tag->term_id,
                'post_tag',
                [
                    'name' => $lowercase_tag,
                ]
            );
        }

    }
1

Just use the Css for that. Why do you wanna change it on MySQL? I suggest text-transform: lowercase for this.

Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.