I am trying to set post terms to a custom taxonomy

by Scott Cop   Last Updated July 11, 2019 19:08 PM - source

I have a custom taxonomy that I would like to update on posts using a PHP function. An example of what I am trying to achieve is the following:

Array
(
    [0] => WP_Term Object
        (
            [term_id] => 183
            [name] => Spotlight
            [slug] => spotlight
            [term_group] => 0
            [term_taxonomy_id] => 183
            [taxonomy] => deals_tiers
            [description] => 
            [parent] => 0
            [count] => 5
            [filter] => raw
            [term_order] => 0
        )    
)

I am trying to set this on posts that have no data in these fields. This can be achieved in the backend by checking the "Spotlight" checkbox but I would like to do this via a function. Any help would be greatly appreciated.



Related Questions





Taxonomy Term Variable within Foreach Loop

Updated July 26, 2015 13:03 PM

Why does wp_remove_object_terms not work?

Updated April 01, 2018 06:08 AM