Created
January 22, 2019 04:06
-
-
Save msaari/eede06d1b67ddba6197b3726b7426b29 to your computer and use it in GitHub Desktop.
Flexible content relationship fields
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 | |
add_filter( 'relevanssi_content_to_index', 'rlv_relationship_content', 10, 2 ); | |
function rlv_relationship_content( $content, $post ) { | |
global $wpdb; | |
$relationships = unserialize( $wpdb->get_var( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key LIKE 'sidebar_groups_%_people'" ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions | |
if ( ! is_array( $relationships ) ) { | |
$relationships = array( $relationships ); | |
} | |
foreach ( $relationships as $related_post_id ) { | |
$content .= ' ' . get_the_title( $related_post_id ); | |
} | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment