add_meta example

if ( $pid ) {
                if ( is_wp_error( $pid ) ) {
                    $x = new WP_Ajax_Response(
                        array(
                            'what' => 'meta',
                            'data' => $pid,
                        )
                    );
                    $x->send();
                }

                $mid = add_meta( $pid );
                if ( ! $mid ) {
                    wp_die( __( 'Please provide a custom field value.' ) );
                }
            } else {
                wp_die( 0 );
            }
        } else {
            $mid = add_meta( $pid );
            if ( ! $mid ) {
                wp_die( __( 'Please provide a custom field value.' ) );
            }
        }
// Convert taxonomy input to term IDs, to avoid ambiguity.     if ( isset( $post_data['tax_input'] ) ) {
        foreach ( (array) $post_data['tax_input'] as $taxonomy => $terms ) {
            $tax_object = get_taxonomy( $taxonomy );

            if ( $tax_object && isset( $tax_object->meta_box_sanitize_cb ) ) {
                $translated['tax_input'][ $taxonomy ] = call_user_func_array( $tax_object->meta_box_sanitize_cb, array( $taxonomy$terms ) );
            }
        }
    }

    add_meta( $post_id );

    update_post_meta( $post_id, '_edit_last', get_current_user_id() );

    $success = wp_update_post( $translated );

    // If the save failed, see if we can sanity check the main fields and try again.     if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) {
        $fields = array( 'post_title', 'post_content', 'post_excerpt' );

        foreach ( $fields as $field ) {
            if ( isset( $translated[ $field ] ) ) {
                
Home | Imprint | This part of the site doesn't use cookies.