Redirecting to another URL after deletion of posts (1 post)

  1. Nishant
    Posted 2 years ago #

    On wordpress site http://www.www.example.com/ there are 540000+ posts added within website, I want to reduce some of post from them to enhance site speed.

    I've installed new wordpress at http://www.www.example.com/business-consultants/ at new wordpress I've moved 3135 posts which have 'Business Consultants' tag assigned on http://www.www.example.com/

    Currently I've set 301 redirect on http://www.www.example.com/ to redirect its posts with tag 'Business Consultants' to new wordpress with URL's post slug , that is
    http://www.www.example.com/{slug} => http://www.www.example.com/business-consultants/{slug}
    Here , for this redirect , I'm checking post tag and post slug and redirect it to new wordpress , following is code used for it.

    function bulk_301_redirect()
    		$status = 301;
    		if (is_single())
    			global $post;
    			$posttags = get_the_tags();
    			if ($posttags)
    				foreach($posttags as $tag)
    					if($tag->name == 'Business Consultants')
    						$location = 'http://www.www.example.com/business-consultants/' . strtolower($post->post_name);
    						wp_safe_redirect( $location, $status );
    	add_action( 'template_redirect', 'bulk_301_redirect' );

    But, I wants to remove these posts to reduce database so that site's speed will get increase , is there any possible solution for that I can apply for http://www.www.example.com/ to redirect on new wordpress after deletion of these posts.

Topic Closed

This topic has been closed to new replies.