EDIT I changed it to

    update_post_meta($pid,"Make", $_POST['Make']);

    update_post_meta($pid,"Year", $_POST['Year']);

    update_post_meta($pid,"Model", $_POST['Model']);

    update_post_meta($pid,"Trim", $_POST['Trim']);

And now it is working intermittently


I am updating meta boxes I created. They function flawlessly on the back-end. But on the front end I am having limited success. Firebug says the POST request has the values in them but they are not ending up in the database.

Can anyone tell me why?

add_post_meta($pid, 'Year', $_POST['Year'], true);

is posting the meta key but not the meta value of a select box?

More information available if you need just let me know what it is.

EDIT TO PROVIDE MORE CODE This a condensed version of the form

    <form method="post" <?php echo $enc; ?>  action="<?php 
     echo post_new_with_pid_stuff_thg($pid,  
     $new_auction_step);?>" > 
     <ul class="post-new">

    <?php do_action('cn_before_image_upload');

update_post_meta($pid, 'Make', $_POST['Make'], true);

            update_post_meta($pid, 'Year', $_POST['Year'], true);

    update_post_meta($pid, 'Model', $_POST['Model'], true);

    update_post_meta($pid, 'Trim', $_POST['Trim'], true);

This is the before_image_upload in functions.php

        add_action('cn_before_image_upload', 'custom_nate_car');

       function custom_nate_car(){

      include_once 'select.php';
     global $wpdb;
     <script type="text/javascript">
        var id = $("select#Year option:selected").attr('value');
        $.post("<?php bloginfo('template_url');?>/select_type.php", {id:id},  

       $('select#Make').change(function() {
        var id2 = $("select#Make option:selected").attr('value');
        $.post("<?php bloginfo('template_url');?>/select_model.php", {id2:id2}, 

        $('select#Model').change(function() {
        var id3 = $("select#Model option:selected").attr('value');
        $.post("<?php bloginfo('template_url');?>/select_trim.php", {id3:id3}, 
        var year = $("select#Year option:selected").attr('value');
        var make = $("select#Make option:selected").attr('value');
        if(year>0 && make>0)
            var result = $("select#Make option:selected").html();
            $("#result").html('your choice: '+result);
            $("#result").html("you must choose two options!");
        return false;


    <h2>Car YEAR/MAKE/MODEL/TRIM:</h2><br />
    <select name="Year" class="do_input" size="20" id="Year">
        <?php echo $opt->getYear(); ?>
    <select name="Make" class="do_input" size="20"  id="Make">
    <select name="Model" class="do_input" size="20" id="Model">

    <select name="Trim" class="do_input" size="20" id="Trim">

    <br /><br />

the select.php that the jquery calls is formatted like this

class selectList {

public function getModel(){
    global $wpdb;
    $sql = $wpdb->get_results(

        SELECT DISTINCT model, make

        FROM wp_car_details 

        WHERE make = '$_POST[id2]'

        ORDER BY model ASC


    foreach ($sql as $res) {
    echo '<option value="'.$res->model.'">'.$res->model.'</option>';

one public function for each of the select boxes. is there a problem with my loop?

EDIT Did var_dump($_POST);

Looks like the select values are not going in into the $_POST array but showing fine in firebug.

  • Can you add more code? Also I think that you'll use update_post_meta in place of add_post_meta. See the Codex for better knowledge. – Chinmoy Kumar Paul Aug 9 '14 at 3:17
  • Please don't post the same question twice. If you need to add more info, do it as an edit in your original post. Thank you – Pieter Goosen Aug 9 '14 at 4:29
  • This is an exact duplicate (double post) of Custom Meta Boxes Not Updating From Front End – Pieter Goosen Aug 9 '14 at 4:31
  • Sorry for the duplicate.. It didn't feel like I was doing that when I posted this... Problem corrected – Nathan Aug 9 '14 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.