【问题标题】:How to remove tag from url如何从网址中删除标签
【发布时间】:2013-10-24 12:53:44
【问题描述】:

我想从 url 中删除标签,以帮助 Google 获得最佳 SEO。例如:

旧网址:

example.com/tag/hello

我希望它是:

example.com/hello

我如何在 wordpress 中做到这一点?以及如何直接从旧网址制作网址?

我在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 );
    }

此代码使任何 url 像:

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

成为:

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

请帮忙删除标签。

【问题讨论】:

  • 您需要更改 register_taxonomy 标签 rewrite slug。或在 .htaccess 中编写自定义重写规则,但它可能与具有与标签相同的重写 slug 的页面冲突。在 wordpress 网站检查 Here
  • 这个插件可能也有帮助Plugin。这是多站点wordpress的解决方案Click here
  • 不适用于标签 :( 有什么帮助吗??

标签: wordpress url tags


【解决方案1】:

我发现这个插件可以从 URL WP-No-tag-base 中删除标签

【讨论】:

    猜你喜欢
    • 2017-11-22
    • 1970-01-01
    • 1970-01-01
    • 2013-05-17
    • 2021-03-17
    • 2020-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多