2024 - 3

//show custom post type in archives.
function ns_set_archive_post_types($query){
    
    // We cannot use 'is_archive' here because post type archives should not be included
    $is_target_query = 
            !is_admin() && 
            $query->is_main_query() && 
            ($query->is_date || 
            $query->is_author || 
            $query->is_category || 
            $query->is_tag || 
            $query->is_tax); 
            
    if($is_target_query){
        $target_types = array('post', 'ns_book_cpt');
        $query->set('post_type', $target_types);
    }
}
add_action('pre_get_posts', 'ns_set_archive_post_types', 10, 1);

ref:https://www.rafaelcardero.com/courses/post-types-in-wordpress/l/109/

First, use
`
SHOW BINARY LOGS;
SHOW MASTER LOGS;
`
to find the binlog name, then use the magic quote as below

Here is the magic

purge binary logs to 'mysql-bin.****';

* is the name of latest binary log file.

This is safe and quick, and can get more free space.