Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

we have an image viewer on our website where admins can tag images thought ajax (new feature on Wordpress 3.0). We are tagging just fine, but we need to filter when they were tagged. We are using normal add_post_meta to update the tagging for the images but I would like to know what's best way to attach time/date on it.

this is our ajax format

$imgID = (!empty($_POST['imgID'])) ? (int) $_POST['imgID'] : '';
            $value = (!empty($_POST['value'])) ? trim(stripslashes($_POST['value'])) : '';
            $action = (!empty($_POST['act']) && in_array($_POST['act'], array('add', 'remove'))) ? $_POST['act'] : 'add';
            if (!empty($imgID) && !empty($value))
            {
                if ('remove' == $action)
                    delete_post_meta($imgID, 'image_tag', $value);
                else if ('add' == $action)
                {
                    $ctags = get_post_meta($imgID, 'image_tag');
                    if ((is_array($ctags) && !in_array($value, $ctags)) || !is_array($ctags) || !$ctags)
                        add_post_meta($imgID, 'image_tag', $value);
                }
            }

            exit;

My first thought is to create new db table. but if there is something easier that I am missing on WP it would be awesome to know.

thanks in advance

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.