Support » Plugins » Hacks » Custom db-query hooked with save post?

  • Hi all!
    I’m using the add meta box function on the post/edit page. I would like to add my special content to the database, but somehow it is not working, i can’t hook my database query into save post. Here is what i’m using, please help me notice what is wrong.

    add_action('save_post', 'custom_content');
    function custom_content() {
            // return $post->ID;
            global $post;
            global $wpdb;
            $wpdb->query("UPDATE wp_customcontent SET fieldid = 7 WHERE ID = 2 AND postID = 10");

    Of course i will not using this on my site, it is just for testing purposes. If i use the query in phpmyadmin, it is working, but it seems it is not happening if i just hook it to save_post.

    P.S. adding post meta is not a solution for me, please do not mention it, as i’m not saving 1-2 data, i’m saving about 17 data to one custom-content, and for every post, there are a few custom-contents related (so with 4-5 custom content, i would have to add 4 or 5 x 17 post meta field. It is simply not good, i want to save it into my own table. Thanks!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom db-query hooked with save post?’ is closed to new replies.