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
-
Category
-
Programming languages
Installing Instruction
How to Add Snippets into the functions.php File of the Active Child Theme
- Copy the required code snippet to your clipboard.
- Navigate to WordPress Dashboard > Appearance > Theme File Editor.
- Click the functions.php tab to open the file.
- Paste the code snippet below the existing code in the Selected file content: area.
- 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
-
Category
-
Programming languages