Title: Attachments
Last modified: April 2, 2023

---

# Attachments

 *  Resolved [321abc](https://wordpress.org/support/users/deraxia/)
 * (@deraxia)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/attachments-51/)
 * I’m using Relevanssi to index my attachments. I only want them to show up in 
   search results for logged in users. Is there any way that can be done?
 * I hope you can help, this is a great plugin. Normally, I can set a post status
   to private to keep logged out users from getting it in search results but not
   sure what I can do in this case.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/attachments-51/#post-16619083)
 * Unfortunately, you can’t just make an attachment private. That would be a neat
   solution. However, you can do this:
 *     ```wp-block-code
       add_filter( 'relevanssi_post_ok', function ( $show, $post_id ) {
           if ( ! is_user_logged_in() ) {
               $post = relevanssi_get_post( $post_id );
               if ( 'attachment' === $post->post_type ) {
                   $show = false;
               }
           }
           return $show;
       }, 11, 2 );
       ```
   
 * This will exclude the `attachment` posts from the search for non-logged-in users.
 *  Thread Starter [321abc](https://wordpress.org/support/users/deraxia/)
 * (@deraxia)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/attachments-51/#post-16619108)
 * That worked, thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Attachments’ is closed to new replies.

 * ![](https://ps.w.org/relevanssi/assets/icon-256x256.png?rev=3529670)
 * [Relevanssi - A Better Search](https://wordpress.org/plugins/relevanssi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/relevanssi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/relevanssi/)
 * [Active Topics](https://wordpress.org/support/plugin/relevanssi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/relevanssi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/relevanssi/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [321abc](https://wordpress.org/support/users/deraxia/)
 * Last activity: [3 years, 2 months ago](https://wordpress.org/support/topic/attachments-51/#post-16619108)
 * Status: resolved