How can I add programmatically custom taxonomy terms to a custom type post when saving posts?

So, to answer my own question: I haven’t found any solution inside wp_insert_post_data. I suspect that the problem is connected to the fact that when wp_insert_post_data is executed the post in question is not yet in the database. And albeit I didn’t manage to find it in taxonomy.php, it is logical to assume that the … Read more

How do I get a meta value from WP_Query?

I’ve found a solution to my problem myself. Since none of the already existing answers solved the problem, I figured I could best post mine here to help people with similar problems. The solution: if($res->have_posts()) { $id = $mail_res->posts[0]->ID; // blindly assuming there is only 1 post having baz = baz_value $true_baz = get_post_meta($id, ‘baz’)[0]; … Read more