update a meta field value based on category terms.

Support General update a meta field value based on category terms.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #7980
    brkardbrkard
    Participant

    Hi.

    I want to update one meta field value based on category.

    My post meta field name is "ae_post_template"

    I want to do something like that.

    if current post category is "cat1"
    update post meta to "1"

    if current post category is "cat2"
    update post meta to "2"

    I am doing with this with an another plugin with this code below:

    function wpufe_update_post_price( $post_id ) {
    if (has_category('cat1',$post_id))
    {
    update_post_meta( $post_id, 'ae_post_template', 1 );
    }
    if (has_category('cat2',$post_id)) {
    update_post_meta( $post_id, 'ae_post_template', 2 );
    }

    }
    add_action( 'wpuf_add_post_after_insert', 'wpufe_update_post_price' );
    add_action( 'wpuf_edit_post_after_update', 'wpufe_update_post_price' );

    I want to do this with backend and also with front end form extension.

    With adding new posts and update posts..

    Can you help me about this by giving a simple code working with metabox plugin ?,

    Thanks

    #8007
    brkardbrkard
    Participant

    Hi.

    I find a solution for this...
    You can ignore this thread.
    Thanks

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘update a meta field value based on category terms.’ is closed to new replies.