Duplicating Posts Due to Images

  • parkerwest

    #6476

    Hello,

    I’ve noticed since the last update that the theme is creating an extra page due to the image included in a post. It resembles a blog post but without the content in the original post. Is there any way to get rid of these excess pages?

    Example:

    Original Post:

    http://www.cardpaymentoptions.com/credit-card-processors/first-american-payment-systems/

    Duplicated Image Post:

    http://www.cardpaymentoptions.com/credit-card-processors/first-american-payment-systems/attachment/first-american-payment-systems-2/

    Prasanna SP

    #33384

    It’s not a duplicate post. It’s rather a attachment post. You may consider attachments to be redirected to parent post.

    This goes in your child-theme’s functions.php (between <?php and ?>). Untested, should work though!

    function redir_attach_to_post() {
    if ( is_attachment() ) {
    wp_redirect(get_permalink($post->post_parent));
    }
    }
    add_action('init','redir_attach_to_post');

    parkerwest

    #33385

    Hi Prasana,

    I added this to my functions.php file but the redirect does not appear to be working. I would also prefer to “noindex” these pages. Do you have a solution for that as well?

    Prasanna SP

    #33386

    WordPress SEO by Yoast has the option to redirect attachment URL’s to parent post URL. Ditch that buggy All in One SEO Pack and grab WordPress SEO by Yoast plugin.

    parkerwest

    #33387

    Switching my SEO plugin is not an option at this time. All in One SEO Pack has a few features not included in Yoast that I use. I only really care about adding an “noindex” tag to these pages. Any thoughts on how to accomplish that?

    Prasanna SP

    #33388

    Try this,

    function noindex_for_attachments() {
    if( is_attachment() ) {
    echo '<meta name="robots" content="noindex" />';
    }
    }
    add_action('wp_head','noindex_for_attachments');

    parkerwest

    #33389

    That did the trick. Thanks Prasanna!

    Mod

    Kenneth John Odle

    #33390

    Keep in mind that not all search engines will honor that request, however. But I believe Google plays nice.

    Marking thread as resolved. You can do this yourself as well.Marking thread as resolved. You can do this yourself as well.

    Prasanna SP

    #33391

    Marking thread as resolved. You can do this yourself as well.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.