Deleting Custom Taxonomy Term only increments tag_ID

I’m not sure why you’re seeing the ID increment, however one problem is that your function call to get_terms() needs to include an array of taxonomy names as the first parameter. In your case, you just need to include an array with a single taxonomy name. For example: $existing_terms = get_terms(array(‘custom_taxonomy’), array( ‘hide_empty’ => false … Read more

Get posts from taxonomy URL

So I’m taking some liberties with this, I’m assuming a couple things: You know the taxonomy the term belongs to You have the term archive link So if I have the term archive link: $url=”http://www.example.com/taxonomy/term/”; I know that the last part of that url is going to be the terms slug. I can use the … Read more

Get terms cross-taxonomy query

All right, few hours of figuring it out, but I made it: I had to wrap the whole thing into a wp_query, querying the current ‘category’ term and then use get_the_terms instead of get_terms to get the terms for the current post query, then remove duplicates and echo it in a foreach loop similar to … Read more

Same taxonomy for different object types

Those are different object types that belong to different tables and hence can have same primary key ID. –> Even though these are different types, all are being stored in one table i.e. wp_posts with post_type = the different types. Check the table structure for clarity. So there won’t be any same ID conflict. if … Read more

Search Custom Post Type & Taxonomies

For now I’ve just redirected the default search string (www.sitedomain.com/?s=keyword) to www.sitedomain.com/trade/keyword, (trade is my custom taxonomy) although I’m pretty sure this isn’t the correct or best way to do it so it’d be great if someone else has a better solution. Here is the code for redirecting the search string: function redirect_search() { if … Read more

One query to get posts and their taxonomy terms

According to user Otto, who provides a good explanatory answer to a similar question, you can safely call wp_get_post_terms() a number of times because WordPress’s internal query caching system is primed before the loop begins, and subsequent calls to wp_get_post_terms() will hit the cache rather than the query: Post meta information is automatically cached in … Read more