Page 1 of 1

Searching through contents of attachment files

Searching through contents of attachment files

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
Examples: "MacOS X - Your question", "MS Word - Your Tip or Trick".

Please note that switching to another language when reading a post will not work!
Posts will not have a translated counterpart.

RSS Feed

Home Forums Web Development Searching through contents of attachment files

Tagged: ,

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


    WordPress supports the uploading of attachment files natively, but the attachment search is possible only by title/name. Is there any wordpress plugin that search in the contents of attachment files as well?

    Need some suggestions.



    Hi GerardKangley,

    Not to my knowledge. It would mean that your server has to search and/or index all attachments (I assume you mean files like PDF, Word, ZIP, etc and not just images) – which would come with a lot of work (for the server).

    This little code (add to functions.php – and beware that I have not tested this) will add searching for attachments, but it will not look into the attachments:

    function attachment_search( $query ) {
        if ( $query->is_search ) {
           $query->set( 'post_type', array( 'post', 'attachment' ) );
           $query->set( 'post_status', array( 'publish', 'inherit' ) );
       return $query;
    add_filter( 'pre_get_posts', 'attachment_search' );

    Your question is nothing new though, and I suppose the WordPress team has chosen not to include this because of resource concerns.
    See for example this StackOverflow question where they suggest using Google for this. Some other suggestions are mentioned as well, but it looks like none really answer your question.



    Thanks for your suggestion Hans it’s really helpful but I got the solution with the help of my friend. He suggested me to use the WordPress Plugin named “Full Text Search” plugin. It’s not only used for the searching website content but also searching the content through the attachments as well. It solves my problem.



    Hi gerardkangley. Thanks for suggesting the plugin but it is to inform you that name you mentioned of a plugin is not correct and it doesn’t appear in any searches of a search engine. The plugin name I found is “WordPress Full Text Search” and I think you are referring to the same one and might have forgot to write it’s full name.
    Are you agree with me or not? 

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

You must be logged in to reply to this topic.