Quantcast
Channel: Toolset » All Posts
Viewing all articles
Browse latest Browse all 20145

Field to Save as Taxonomy

$
0
0

Hi,

I have a custom field "wpcf-contract" which i like to save as a taxonomy as well "contract-taxo".

Based in the forum, i have created this:

                if (isset($_POST['wpcf-contract']))
        {
            // add it to saved post meta
        $tag = array( 27 ); // add the id of your tag
        $taxonomy = 'contract-taxo'; // add the slug of the taxonomy
        wp_set_post_terms( $post_id, $tag, $taxonomy );

Now, its just saving to 1 particular term, "Sale". How do i code this, when user selects "Rent" in "wpcf-contract" field, it will save as "Rent" in taxonomy.

Thanks for your help.


Viewing all articles
Browse latest Browse all 20145

Trending Articles