• Hi there!

    I have written a class to attach terms to a custom post type on ‘draft_to_publish’ hook, the class is really simple but, even though it is triggered when publishing the post, it doesn’t cause any effect on the wp_term_relationship table.
    After too much research, it seems like Types is the cause.
    Is there any way to programmatically do what I want in the function without uninstalling your plugin?

    class setCategoriesRight
    {
        public function __construct()
    	{
            add_action( 'draft_to_publish', array( $this, 'publish_post' ) );
        }
        public function publish_post($post)
    	{
            if('myposttype' == $post->post_type)
    	{
    		$post_id = $post->ID;
    		$categories = array(11, 12, 13, 14, 15);
    		wp_set_post_categories( $post_id, $categories, true);
    	}
    }
    }
    new setCategoriesRight;

    https://www.ads-software.com/plugins/types/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘problem with wp_set_post_categories’ is closed to new replies.