Last active
April 25, 2018 18:25
-
-
Save djrmom/9b9d16c3f08cccd60d88045b7c6f866a to your computer and use it in GitHub Desktop.
facetwp search attachments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * make sure both publish and inherit (for attachments) are searched on the search page | |
| * Relevanssi has an option to index attachments but the query facet detects does not include attachments | |
| * because it does not include post_status inherit | |
| */ | |
| add_action( 'pre_get_posts', function( $query ) { | |
| if ( $query->is_search() ) { | |
| $statuses = $query->get( 'post_status' ); | |
| $query->set( 'post_status', array_merge( (array)$statuses, array( 'publish', 'inherit' ) ) ); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment