Enable Search for Media Attachments

This snippet extends JetSearch to include WordPress attachment post types in search results. It makes attachments searchable via JetSearch and displays a thumbnail for image attachments.

Specifications
Enable Search for Media Attachments
21 September, 2025
  • Plugin
    • JetSearch
  • Category
    • Filters & Search
  • Programming languages
    • PHP
Source code

Installing Instruction

How to Add Snippets into the functions.php File of the Active Child Theme

Attention: Create a site backup before applying any changes to functions.php.

This ensures that you can restore the website if something goes wrong after adding the code snippet.

  1. Copy the required code snippet to your clipboard.
  2. Navigate to WordPress Dashboard > Appearance > Theme File Editor.
  3. Click the functions.php tab to open the file.
  4. Paste the code snippet below the existing code in the Selected file content: area.
  5. Click the "Update File" page.

Example Use Case

Use this snippet when you want JetSearch to return media attachments alongside posts and pages. Images will display thumbnails, while other media types (PDFs, videos, audio) will still appear in results without thumbnails.
Applicable scenarios:

  • Photography sites — let users search for images by title or keywords.
  • Content libraries — search uploaded PDFs, videos, or audio files.
  • Blogs or portfolios with media — include all uploaded media in search results for easier discovery.
  • AJAX search dropdowns — display image thumbnails for image attachments to improve UX.
Specifications
Enable Search for Media Attachments
21 September, 2025
  • Plugin
    • JetSearch
  • Category
    • Filters & Search
  • Programming languages
    • PHP
Source code

Let’s build together

Have your own solution?

Came up with a great solution and want to show it to the Crocoblock community?

Request a new feature

Leave a feature request through GitHub, and our developers will consider it