My wordpress site has nearly 3000 posts that was deleted recently. Instead of showing error code 404, How do I show error code 410 to all deleted or not found posts and pages?
You can either use this plugin which will come handy for you, or you can follow the given steps to achieve this without using any plugin.
404.php
file.Code for 404.php
$custom_410_page_ID = 25;//Error 410 page ID
header($_SERVER["SERVER_PROTOCOL"] . " 410 Gone");
header("Refresh: 0; url=" . get_permalink($custom_410_page_ID));
exit();
Now when any on visit your old URL or mistype any URL it will be redirected to Error 410 page with 410 status code to .
Reference: Move All 404 To 410
Hope this helps!