Attachment search not working correctly

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Attachment search not working correctly

This topic contains 3 replies, has 2 voices, and was last updated by

1 year, 12 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #25549


    Hi there.

    I’m developing a website for my client. I have run into a problem with ASP and searching attachments.

    First of all, the email address for the account is my clients so I will only see support request updates through your website unless you can let me know at [email protected]

    The search works perfectly but when clicking on a search result for an attachment the “attachment parent post” will not be displayed. Only the attachment JPG is displayed. I have of course set up the plugin to return attachments in the parent post.

    Search form “Website search”

    So, here’s an example:
    Search for “Braunton Church Medieval”

    Result: at the bottom of the search results you will two pictures of churches which are attachments with the search term. Clicking on either of these results in:

    What should be returned is this:

    it’s critical that this works because this is one of the main reasons why we purchased the plugin.

    Can you take a look please and let me know what the solution is.

    In advance, thank you.
    Rees Kenyon – web dev and designer


    Hi Rees,

    Thank you for all the details, it helps us a lot.

    Okay, so I checked the given posts and their attachments, and I see the problem. The given images are not actually attached to that post, but only used in their contents. You can check that this way:
    – Open the post editor and click “Add Media”:
    – Click the Media library:
    – Change “Uploaded to this”:
    As you can see, there is only one image attached to the post, when searching that image name, the post is returned as it should.

    When the plugin indexes the attachments, it checks the database for the attachment parents, but in this case their parents are not defined in the database, because they are not attached to any post, but simply uploaded as images (or the parent was deleted).
    Unfortunately currently there is no way of getting in which post was the attachment image used, as the post contents does not contain a connection between the image object, only the image URL.

    I am not sure if there is a way to natively change the attachment parent IDs via editor, but there might be plugins out there for this purpose.

    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)



    Hi Ernest.

    Thank you for taking the time to explain why the attachments aren’t recognised in the page or post.

    I have found a workaround which might be really useful for you to use as a future suggestion for others.

    I’m using themify builder and like many other visual composition software it breaks out of the usual WordPress publishing methodology.

    My trick is to add a text box (builder component) at the bottom of the post and add all the media attachments used in the this post. I then add a <noscript> at the beginning of these attachments and a </noscript> at the end in the tinymce text view option. This in turn attaches all the images to the post but of course doesn’t display or load them so they have no effect on page load, the DOM, page rendering and probably more importantly load balancing.

    You can see how I did this here if you want to take a look:



    Hi Rees,

    Wow, that actually works. What an interesting solution, thanks for sharing. I will take a note of this for sure.

    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)

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

You must be logged in to reply to this topic.