Skip to content

Instantly share code, notes, and snippets.

@keesiemeijer
Last active February 5, 2016 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keesiemeijer/abfc5af9662bc781e725 to your computer and use it in GitHub Desktop.
Save keesiemeijer/abfc5af9662bc781e725 to your computer and use it in GitHub Desktop.
Add post terms to related posts results
<?php
add_filter( 'related_posts_by_taxonomy_posts_clauses', 'rpbt_post_where', 10, 4 );
function rpbt_post_where( $pieces, $post_id, $taxonomies, $args ) {
global $wpdb;
$pieces['select_sql'] .= " , GROUP_CONCAT( DISTINCT tt.term_id SEPARATOR ',' ) as related_terms ";
return $pieces;
}
@keesiemeijer
Copy link
Author

For mysql only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment