Google で最高の SEO を実現するために、URL からタグを削除したいと考えています。例えば:
古い URL:
example.com/tag/hello
私はそれが欲しい:
example.com/hello
ワードプレスでそれを行うにはどうすればよいですか?また、古い URL から直接 URL を作成するにはどうすればよいですか?
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/
タグの削除にご協力ください。