Created
September 3, 2018 05:55
-
-
Save msaari/a8be590001ef26137fb9226414fb4c82 to your computer and use it in GitHub Desktop.
Index attachment titles for parent
This file contains 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 | |
// Add this function to your theme functions.php and reindex. | |
add_filter( 'relevanssi_content_to_index', 'rlv_index_attachment_names', 10, 2 ); | |
function rlv_index_attachment_names( $content, $post_id ) { | |
$attachments = get_children( | |
array( | |
'post_parent' => $post_id, | |
'post_type' => 'attachment', | |
) | |
); | |
foreach ( $attachments as $attachment ) { | |
$content .= ' ' . $attachment->post_title; | |
} | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment