Guest User

Untitled

a guest
Sep 18th, 2019
90
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. add_action( 'save_post_' . cptsatwcp_post_type_name(), 'cptsatwcp_update_post_terms', 10, 3 );
  4.  
  5. /**
  6. * @param integer $post_ID
  7. * @param WP_Post $post
  8. * @param bool $update
  9. */
  10. function cptsatwcp_update_post_terms( $post_ID, $post, $update ) {
  11. if ( $post->post_type !== cptsatwcp_post_type_name() ) {
  12. return;
  13. }
  14. if ( ! $update ) {
  15. $args = array(
  16. 'taxonomy' => cptsatwcp_taxonomy(),
  17. 'hide_empty' => false,
  18. 'fields' => 'ids',
  19. );
  20. $terms = get_terms( $args );
  21. wp_set_post_terms( $post_ID, $terms, cptsatwcp_taxonomy() );
  22. }
  23. }
  24.  
  25. function cptsatwcp_post_type_name() {
  26. return 'kreditnaya-karta';
  27. }
  28.  
  29. function cptsatwcp_taxonomy() {
  30. return 'cities';
  31. }
RAW Paste Data