Set terms in a custom post

I know this is an old question, but the tax_input array should probably look like this since it appears to be hierarchical like a category: ‘tax_input’ => array(‘artist-category’ => array( 3 ) //use the ID of the category, not the name of the category From WordPress Codex on wp_set_post_terms If you want to enter terms … Read more

Remove category from query (show all posts in archive.php) pre_get_posts()

Just unsetting the cat variable probably isn’t enough. The pre_get_posts hook happens after the query variables have already been parsed. So there’s probably a tax_query with the taxonomy = category and the terms = your category. You’re already dumping the $query in your code, presumably for debugging. So, look at what you’re actually dumping. Do … Read more

get_term and get_term_by return null or false, even though term exists

To use get_term_by we need the term object before it gets deleted. Therefore, we should use the action hook delete_term_taxonomy that runs before the term is deleted. Now, we can go ahead and perform some tasks such as deleting all the postmeta related to the term being deleted. The code is: add_action( ‘delete_term_taxonomy’, function($tt_id) { … Read more

How do I taxonomy terms based on terms they are used alongside?

So my solution on this kind of problems where we have a very complex set of rules is to avoid doing new SQL just for my solution because if you have to explain it to a beginner it gets hairy. My solution: function get_term_union( $taxonomy, $tax_query, $post_type=”post” ){ $args = array( ‘post_type’ => $post_type, ‘tax_query’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)