-
-
Save markjaquith/681af58ce22d79c08c09 to your computer and use it in GitHub Desktop.
How to use the pre_get_comments action to alter comment meta query vars
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 | |
function cws_pre_get_comments( $comments ) { | |
$comments->query_vars['meta_key'] = 'foo'; | |
$comments->query_vars['meta_value'] = 'bar'; | |
// Because at this point, the meta query has already been parsed, | |
// we need to re-parse it to incorporate our changes | |
$comments->meta_query->parse_query_vars( $comments->query_vars ); | |
} | |
add_action( 'pre_get_comments', 'cws_pre_get_comments' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you need to do:
before doing