有date_query 如果可以利用WordPress查询API,则SQL查询不是一种好的做法:
$pid = 1; // post ID here
$args = array(
    \'posts_per_page\' => -1,
    \'post_type\' => \'post\',
    \'date_query\' => array(
        array(
            \'year\'  => get_the_date(\'Y\', $pid),
            \'month\' => get_the_date(\'m\', $pid)
        ),
    ),
);
$posts = get_posts( $args );
print_r( $posts );
 希望这有帮助。