Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter momasvii

    (@momasvii)

    I have fixed my issue. I needed to change category to the type in the wp_term_taxonomy table.

    Thank you for the help!

    Thread Starter momasvii

    (@momasvii)

    Hi,

    I have change my code to the below and even though my success message is ‘2’ i don’t see anything in the DB.

    EDIT: I have it working with this code but I do not want it to create a new term in the wp_terms table. How can I stop this from happening even though the slug already exists in there.

    Thanks

    $term_taxonomy_ids = wp_set_object_terms( $post_ID, ‘new-scenario’, ‘category’, false );
    if ( is_wp_error( $term_taxonomy_ids ) ) {
    // There was an error somewhere and the terms couldn’t be set.
    echo “1”;
    } else {
    echo “2”;
    // Success! The post’s categories were set.
    }`

    Am I using the ‘category’ variable correct because I’m not sure what that does.

    Thanks for the help.

    • This reply was modified 9 years, 8 months ago by momasvii.
Viewing 2 replies - 1 through 2 (of 2 total)