How can I check if the current loop is a comment? Something like is_comment()
.
I'm building a custom update_x_meta()
function where we update meta data according to the type, example:
if ( is_single() || is_attachment() || is_page() ) {
// post, page, attachment
update_post_meta($id, $meta_data, $meta_value);
} elseif (is_author()) {
// author page
update_user_meta($id, $meta_data, $meta_value);
} elseif ( is_category() || is_tag() || is_tax() ) {
// taxonomies
update_term_meta($id, $meta_data, $meta_value);
} elseif ( is_comment() ) {
// comment
update_comment_meta($id, $meta_data, $meta_value);
}
I suppose in order to make this work, I will need to target the conditional tags with a specific ID, like is_single($id)
etc. although that may not work given that we can have the same ID for posts, terms...
I feel there should already be an update_x_meta()
type of function in core already.
is_comments_popup()
). Did you mean to check if you are on aWP_Comment_Query
loop?is_single()
will be true even if we are on aWP_Comment_Query
loop. I'm rethinking this approach. Maybe aglobal $post
route...WP_Query
doesn't query the comments, so you have to either query the comments manually byWP_Comment_Query
or check to see if it the post has any comments, and then run the loop. Otherwise, i don't know whenis_comment()
can be true, since comments are manually pulled bycomments_template();
Whenever needed.global $wp_query;
and then use conditions like$wp_query->is_page
etc. The problem is still the same though I guess. Back to the drawing board... =(