• In my project, When I use get_comments with orderby comment_ID. WP will always return nothing.

    my code like:

    $c = array(
    			'post_id' 	=> $memberInfo['id'],
    			'orderby'	=> 'comment_ID',
    			'order'	=> 'DESC',
    			'meta_key'	=> $this->activities_log_key,
    			'offset'	=> $options['num'] * $options['page'],
    			'number'	=> $options['num']
    		);
    $acts = get_comments($c);

    I check the source in wp-includes/comment.php and print the sql and run it in phpmyadmin. If use borderby comment_ID ,it will cause sql error:
    #1052 - Column 'comment_ID' in order clause is ambiguous

    After check the source I thing this is a bug in wp_comment_query’s query builder. It should add tablename before orderby fields.

  • The topic ‘use get_comments with orderby comment_ID not work’ is closed to new replies.