Site logo

[Resolved] Urgent: Marking Deleted Posts As A 410

Home Forums Support [Resolved] Urgent: Marking Deleted Posts As A 410

Home Forums Support Urgent: Marking Deleted Posts As A 410

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2421331
    Growthonics

    Hello, i want to clean up my site. for that i’m going to delete so many posts and i want to mark all of them as a 410 Header code not as a 404 error code.

    I just created 410.php page inside the theme as directed here: https://generatepress.com/forums/topic/custom-410-error-page-2/#post-866500

    But, if i visit the deleted urls it still gives 404 header response. Please help me to fix it.

    Here is the 410.php page

    <?php
    /**
     * The template for displaying 410 pages (Not Found).
     *
     * @package GeneratePress
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    
    get_header(); ?>
    
    	<div <?php generate_do_attr( 'content' ); ?>>
    		<main <?php generate_do_attr( 'main' ); ?>>
    			<?php
    			/**
    			 * generate_before_main_content hook.
    			 *
    			 * @since 0.1
    			 */
    			do_action( 'generate_before_main_content' );
    
    			generate_do_template_part( '410' );
    
    			print "It's 410 Error";
    
    			/**
    			 * generate_after_main_content hook.
    			 *
    			 * @since 0.1
    			 */
    			do_action( 'generate_after_main_content' );
    			?>
    		</main>
    	</div>
    
    	<?php
    	/**
    	 * generate_after_primary_content_area hook.
    	 *
    	 * @since 2.0
    	 */
    	do_action( 'generate_after_primary_content_area' );
    
    	generate_construct_sidebars();
    
    	get_footer();

    I have added example deleted post url for testing in the private information tab.

    Waiting for your response,
    Thanks

    #2421479
    David
    Staff
    Customer Support

    Hi there,

    The Theme doesn’t interfere with rewrite rules or redirects. Generally it will be an SEO or Redirect plugin that is responsible. If those are not in place, then check with your host to make sure there are no htaccess ( or equivalent ) rewrite rules in place.

    #2422582
    Growthonics

    I do not use any rediection plugin. I use Yoast SEO plugin which is not a premium so it does not have any redirection for normal user. i also check with host support they told me that .htaccess file is fine there is no issue of it..

    Also, can you please verify the 410.page and check that is it correct or not?

    Please tell me how do i mark deleted posts as a 410 instead of 404?

    #2422696
    David
    Staff
    Customer Support

    I don’t have a solution for selectively setting a deleted post to a 410.
    There maybe plugins out there that do. But the Theme has no control over the header response.

    The simplest thing i could find on this subject is switching 404 to 410 – see here:

    https://stackoverflow.com/a/42989169

    #2422702
    Growthonics

    Okay, just last question. how do i get the URL of 410.php page?

    i tried this theinsaneapp.com/410.php but it’s showing 404 error page…

    #2423874
    David
    Staff
    Customer Support

    It doesn’t work like that, the header response would need to be a 410 error.
    And therefore you need something that sets that header response.

    Apart from an SEO plugin, you could try either of these:

    https://en-gb.wordpress.org/plugins/ultimate-410/

    https://wordpress.org/plugins/redirection/
    Topic from that plugins support regarding 410 errors:https://wordpress.org/support/topic/converting-a-404-to-a-410/

    This is not a theme related thing, as we don’t redirect, change permalinks or write response headers. So i am afraid thats all i can offer.

    #2446105
    Growthonics

    Thank you, David!

    #2446320
    David
    Staff
    Customer Support

    You’re welcome

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.