Вопрос

I'm using the plugin Wordpress User Frontend and editing the title and content of a post is nice (I managed to change it so I can edit custom post types), but there's no support for editing custom fields. So I have the following code below (not sure if it's too long to have to put on pastebin):

function wpuf_validate_post_edit_submit() {
    global $userdata;

    $errors = array();

    $title      = trim($_POST['wpuf_post_title']);
    $content    = trim($_POST['wpuf_post_content']);
    $tags       = wpuf_clean_tags($_POST['wpuf_post_tags']);
    $cat        = trim($_POST['cat']);
    $post_location  = trim($_POST['wpuf_post_location']);
    echo $post_location;

    if (empty($title)) {
        $errors[] = "Empty post title";
    } else {
        $title = trim(strip_tags($title));
    }

    if (empty($content)) {
        $errors[] = "Empty post content";
    } else {
        $content = trim($content);
    }

    if (!empty($tags)) {
        $tags = explode(',', $tags);
    }

    if (!$errors) {
        $post_update = array(
                'ID'            => trim($_POST['post_id']),
                'post_title'    => $title,
                'post_content'  => $content,
                'post_category' => array($cat),
                'tags_input'    => $tags
        );
        $post_cf = update_post_meta($post->ID,'location',$post_location);
        $post_id = wp_update_post($post_update);
        //var_dump($post_update);

        if ($post_id && $post_cf) {
            echo '<div class="success">Post updated succesfully.</div>';
        }

    } else {
        echo wpuf_error_msg($errors);
    }
}

$post_cf should update the location field that is grabbed from the top of the code ($post_location). Upon echoing the field, it echo's the updated field, but when saving the post ($post_id?) and refreshing the page, the custom field stays the same?

Does anyone know what's going on? I've been at this for over an hour now.

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с wordpress.stackexchange
scroll top