Duplicating Posts Due to Images

  • Anonymous



    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?


    Original Post:


    Duplicated Image Post:




    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() ) {



    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?



    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.



    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?



    Try this,

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



    That did the trick. Thanks Prasanna!


    Kenneth John Odle


    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.



    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.