我想从 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/
请帮助删除标签。