Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'edited_rp_booking_types', 'rp_taxonomy_meta_update_post', 10, 2 );
- function rp_taxonomy_meta_create_post( $term_id, $tt_id ){
- global $wpdb;
- $postID = wp_insert_post( array( 'post_title' => "taxonomy-meta-term-{$term_id}", 'post_type' => 'rp_taxonomy_meta' ) );
- return $postID;
- }
- function rp_taxonomy_meta_update_post( $term_id, $tt_id ){
- global $wpdb;
- if ( !$post_id = post_exists( "taxonomy-meta-term-{$term_id}" ) ){
- $post_id = rp_taxonomy_meta_create_post( $term_id, $tt_id );
- }
- if ( $post_id === 0 || is_null( $post_id ) ){
- return;
- }
- $meta_key = 'booking_type_color';
- $meta_value = esc_attr( $_POST["booking_type_color"] );
- update_post_meta( $post_id, $meta_key, $meta_value);
- }
- function rp_taxonomy_meta_get_meta( $term_id ){
- $post_id = post_exists( "taxonomy-meta-term-{$term_id}" );
- if ( $post_id ){
- return get_post_meta( $post_id, 'booking_type_color' );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement