Yes, Relevanssi can index attachment pages. Have you checked the “attachment” post type?
If you have and you’re still not seeing images in search results, then it’s possible your theme is restricting the post types in the search.
If you search for something that should return an image in the results and then add &post_types=attachment to the end of the search results page URL, does that make the image show up?
It did work when i added &post_type=attachment. I couldn’t find anything in my theme related to attachment search, but I did find this snippet for anyone else that might need it:
function my_attachments_search( $query ) {
if ( !is_search() )
return $query;
$post_types = $query->get( 'post_type' );
if ( ! $post_types || 'post' == $post_types )
$post_types = array( 'post', 'attachment' );
if ( is_array( $post_types ) )
$post_types[] = 'attachment';
$query->set( 'post_type', $post_types );
return $query;
}
// hook our function to the filter
add_filter( 'pre_get_posts', 'my_attachments_search' );
Here’s a more compact version of the function, just for setting the search post types to post and attachment.
add_filter( 'relevanssi_modify_wp_query', 'rlv_post_types' );
function rlv_post_types( $query ) {
$query->set( 'post_type', array( 'post', 'attachment' );
return $query;
}
Is there something slightly off since I got this message:
Parse error: syntax error, unexpected ‘;’ in /home3/dtphost/public_html/example/blog/wp-content/themes/theme/functions.php on line 48
Yeah, it’s missing a closing parentheses:
add_filter( 'relevanssi_modify_wp_query', 'rlv_post_types' );
function rlv_post_types( $query ) {
$query->set( 'post_type', array( 'post', 'attachment' ) );
return $query;
}