How to assign filter-category automatically

Assigning of filter-category automatically (by code in your site) to any post type is necessary when for example a lot of posts should be added by users for example, or by any another reason.  For this should be used WordPress hook save_post

Here is an example how to realize it:

  • open functions.php file of your site current wp theme and drop there next code:
  • 77 here is an example ID of filter-category, and you should write it there correct, test it after the code installation
  • post_type - if you need this operation for only one post-slug.  Comment or remove 'return' in 'if ( $post_type != $post->post_type )' condition