Title: Klian's Replies | WordPress.org

---

# Klian

  [  ](https://wordpress.org/support/users/klian/)

 *   [Profile](https://wordpress.org/support/users/klian/)
 *   [Topics Started](https://wordpress.org/support/users/klian/topics/)
 *   [Replies Created](https://wordpress.org/support/users/klian/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/klian/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/klian/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/klian/engagements/)
 *   [Favorites](https://wordpress.org/support/users/klian/favorites/)

 Search replies:

## Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Yoast SEO - Advanced SEO with real-time guidance and built-in AI] Yoast plugin is not working on WordPress 4.9.8](https://wordpress.org/support/topic/yoast-plugin-is-not-working-on-wordpress-4-9-8/)
 *  [Klian](https://wordpress.org/support/users/klian/)
 * (@klian)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/yoast-plugin-is-not-working-on-wordpress-4-9-8/#post-10566421)
 * Same error here with WP 4.9.8 and Yoast 7.9
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[CPT-onomies: Using Custom Post Types as Taxonomies] Assigning CPT-onomies to Attachments – Not Saving Selection](https://wordpress.org/support/topic/assigning-cpt-onomies-to-attachments-not-saving-selection/)
 *  [Klian](https://wordpress.org/support/users/klian/)
 * (@klian)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/assigning-cpt-onomies-to-attachments-not-saving-selection/#post-5130639)
 * The problem is that the save_post action doesn’t fired up with the edit attachment
   page… so we have to add a new action to execute it.
 * I’ve fixed it editing cpt-onomies/admin.php file:
 * Below line 52:
    `add_action( 'save_post', array( &$this, 'save_post' ), 10, 2);`
 * Add this:
    `add_action( 'edit_attachment', array( &$this, 'save_attachment' ),
   10, 2 );`
 * At the end of the file add this function:
 *     ```
       public function save_attachment($post_id){
       		global $cpt_onomies_manager, $cpt_onomy;
       		// pointless if $_POST is empty (this happens on bulk edit)
       		if ( empty( $_POST ) ){
       			return $post_id;
       		}
   
       		// verify nonce
       		if ( ! ( isset( $_POST[ 'is_bulk_quick_edit' ] ) || ( isset( $_POST[ '_wpnonce' ] ) && wp_verify_nonce( $_POST[ '_wpnonce' ], 'update-' . $post->post_type . '_' . $post_id ) ) || ( isset( $_POST[ CPT_ONOMIES_UNDERSCORE . '_nonce' ] ) && wp_verify_nonce( $_POST[ CPT_ONOMIES_UNDERSCORE . '_nonce' ], 'assigning_' . CPT_ONOMIES_UNDERSCORE . '_taxonomy_relationships' ) ) ) ){
       			return $post_id;
       		}
   
       		// check autosave
       		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){
       			return $post_id;
       		}
   
       		// dont save for revisions
       		if ( isset( $post->post_type ) && $post->post_type == 'revision' ){
       			return $post_id;
       		}
   
       		$post = get_post($post_id);
   
       		// check cpt-onomies
   
       		foreach( get_object_taxonomies( $post->post_type, 'objects' ) as $taxonomy => $tax ) {
   
       			// make sure cpt-onomy was visible, otherwise we might be deleting relationships for taxonomies that weren't even "editable"
       			if ( isset( $_POST[ 'assign_cpt_onomies_' . $taxonomy . '_rel' ] ) && $cpt_onomies_manager->is_registered_cpt_onomy( $taxonomy ) ) {
   
       				// check permissions
       				if ( ! current_user_can( $tax->cap->assign_terms ) )
       					continue;
   
       				// set object terms
       				if ( isset( $_POST[ CPT_ONOMIES_POSTMETA_KEY ][ $taxonomy ] ) ) {
   
       					// need to make sure its an array
       					if ( ! is_array( $_POST[ CPT_ONOMIES_POSTMETA_KEY ][ $taxonomy ] ) )
       						$_POST[ CPT_ONOMIES_POSTMETA_KEY ][ $taxonomy ] = explode( ',', $_POST[ CPT_ONOMIES_POSTMETA_KEY ][ $taxonomy ] );		
   
       					$cpt_onomy->wp_set_object_terms( $post_id, $_POST[ CPT_ONOMIES_POSTMETA_KEY ][ $taxonomy ], $taxonomy );
   
       				}
   
       				// delete taxonomy relationships
       				else
       					$cpt_onomy->wp_delete_object_term_relationships( $post_id, $taxonomy );
   
       			}
   
       		}
       	}
       ```
   
 * This method works for me.

Viewing 2 replies - 1 through 2 (of 2 total)