[SmartCrawl Pro] Attachment page redirect to parent page

By default Wordpress creates a page for every media item uploaded. All of these pages end up in Google search results and look a bit silly. They may have a negative impact on SEO too. It would be very nice to have a checkbox in SmartCrawl Pro to "Redirect image attachment pages". If checked, the following code would need to be executed:

function myprefix_redirect_attachment_page() {?if ( is_attachment() ) {?global $post;?if ( $post && $post->post_parent ) {?wp_redirect( esc_url( get_permalink( $post->post_parent ) ), 301 );?exit;?} else {?wp_redirect( esc_url( home_url( '/' ) ), 301 );?exit;?}?}?}?add_action( 'template_redirect', 'myprefix_redirect_attachment_page' );

The second-best SEO plugin that starts with "Y" does have this feature and there are some plugins available to do this too. It would be really nice to have as part of SmartCrawl Pro!

  • Tony G
    • Mr. LetsFixTheWorld

    Sort of +1 ... Can't that code be replaced with a redirect in .htaccess, or with a plugin like Redirection?

    Somewhat related... In some cases we want those pages to be generated/indexed, and in other cases not. When they are created, if we want them to be public-visible, we should be able to check the SEO. As noted elsewhere, it doesn't make sense to get a bad SEO rating from SmartCrawl for lack of content or keywords when the page is dedicated to an enhancement.

    I don't know if attachments are generated for media that's not stored in the typical date-oriented hierarchy (2018/08/foo.ext), but if so then if a change is implemented for SmartCrawl for this, I hope it includes that concept.

  • Brandon
    • Recruit

    SOLVED

    I just found this feature and it's already in Smart Crawl Pro! It is under the Advanced Tools menu.

    I'm using this on a network installation with this plugin network activated. The Advanced Settings page applies to the entire installation and not a given site. Adding this note in case others have the same issue finding it.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.