Add custom category name as data-filter to switch between these categories

I have a portfolio page where I would like to place three buttons that will switch between different categories. I am using data-filer to sort them into different projects. I am thinking, how can I give this data-filter a category name, so it would switch depending what category and also when adding new post (project) and using any custom category, it would place it right in that portfolio section.

For this page I have this code:

<?php  get_header(); ?>   <div class="container projects-container">  <div class="gallery-nav" align="center">    <button class="btn btn-default filter-button gallery-link" data-filter="all">All</button>    <button class="btn btn-default filter-button gallery-link" data-filter="architecture">Architecture</button>    <button class="btn btn-default filter-button gallery-link" data-filter="furniture">Furniture</button>   </div>   <div class="row">    <?php    $  subs = new WP_Query(      array(        'post_parent' => $  post->post,        'post_type' => 'post',        'meta_key' => '_thumbnail_id'      )   );   if( $  subs->have_posts() ) :      while( $  subs->have_posts() ) :        $  subs->the_post(); ?>    <div class="col-sm-12 col-md-6 col-lg-4 cover-img filter">         <a href="<?php the_permalink(); ?>">       <?php the_post_thumbnail('post-thumbnail', ['class' => 'img-fluid']); ?></a>   </div>   <?php endwhile; ?>  <?php endif; ?>  <?php get_footer(); 

And this jQuery code:

jQuery(document).ready(function(){    $  (".filter-button").click(function(){       var value = $  (this).attr('data-filter');        if(value == "all")       {           $  ('.filter').show('1000');       }       else       {          $  (".filter").not('.'+value).hide('3000');         $  ('.filter').filter('.'+value).show('3000');        }   });    if ($  (".filter-button").removeClass("active")) {    $  (this).removeClass("active");    }    $  (this).addClass("active");  }); 

Magento2 impossible assign products to categories

SQLSTATE[HY000]: General error: 1114 The table 'catalog_category_product_index_tmp' is full, query was: INSERT INTO `catalog_category_product_index_tmp` (`category_id`, `product_id`, `position`, `is_parent`, `store_id`, `visibility`) SELECT 2 AS `category_id`, `cp`.`entity_id` AS `product_id`, IF(ccp.product_id IS NOT NULL, ccp.position, 0) AS `position`, IF(ccp.product_id IS NOT NULL, 1, 0) AS `is_parent`, 10 AS `store_id`, IFNULL(cpvs.value, cpvd.value) AS `visibility` FROM `catalog_product_entity` AS `cp` INNER JOIN `catalog_product_website` AS `cpw` ON cpw.product_id = cp.entity_id INNER JOIN `catalog_product_entity_int` AS `cpsd` ON cpsd.entity_id = cp.entity_id AND cpsd.store_id = 0 AND cpsd.attribute_id = 97 LEFT JOIN `catalog_product_entity_int` AS `cpss` ON cpss.entity_id = cp.entity_id AND cpss.attribute_id = cpsd.attribute_id AND cpss.store_id = 10 INNER JOIN `catalog_product_entity_int` AS `cpvd` ON cpvd.entity_id = cp.entity_id AND cpvd.store_id = 0 AND cpvd.attribute_id = 99 LEFT JOIN `catalog_product_entity_int` AS `cpvs` ON cpvs.entity_id = cp.entity_id AND cpvs.attribute_id = cpvd.attribute_id AND cpvs.store_id = 10 LEFT JOIN `catalog_category_product` AS `ccp` ON ccp.product_id = cp.entity_id WHERE (cpw.website_id = '1') AND (IFNULL(cpss.value, cpsd.value) = 1) AND (IFNULL(cpvs.value, cpvd.value) IN (2, 3, 4)) AND (cp.entity_id IN ('70473', '70478')) GROUP BY `cp`.`entity_id` ON DUPLICATE KEY UPDATE `category_id` = VALUES(`category_id`), `product_id` = VALUES(`product_id`), `position` = VALUES(`position`), `is_parent` = VALUES(`is_parent`), `store_id` = VALUES(`store_id`), `visibility` = VALUES(`visibility`) 

Any help how to solve?