div info
div info

Reputation: 93

How to remove tag from url

I want remove tag from a url to help with Google for best SEO. For example:

old url:

example.com/tag/hello

I want it to be:

example.com/hello

How do I do that in wordpress? And how do I make the url direct from the old url?

I use this code in functions.php:

function stf_redirect_to_post(){
    global $wp_query;

    // If there is one post on archive page
    if( is_archive() && $wp_query->post_count == 1 ){
        // Setup post data
        the_post(); 
        // Get permalink
        $post_url = get_permalink();
        // Redirect to post page
        wp_redirect( $post_url );
    }

This code makes any url like:

http://example.com/tag/sms/

to be:

http://example.com/special-offers/website-messages/

Please help to remove tag.

Upvotes: 1

Views: 2876

Answers (1)

div info
div info

Reputation: 93

I found this plugin to remove the tag from the URL WP-No-tag-base

Upvotes: 1

Related Questions