How to filter custom taxonomy term name, slug, and description?

The default fields name, slug and description are not term metadata, so you should instead use wp_update_term() to update those fields. So just replace those three add_term_meta() with: wp_update_term( $term_id, ‘codes’, [ ‘name’ => $name, ‘slug’ => $slug, ‘description’ => $desc, ] ); Additionally, instead of using $_POST, I would use get_term() to get the … Read more

Display sibling categories on category page

I have a category page, how do i display this category sibling categories on this page as well? I know how to display children categories I think i need to get term_id somehow On a term archive page, e.g. at example.com/category/foo/ (for the default category taxonomy), You can use get_queried_object() to retrieve the term object … Read more

How to get the $meta_type given the $object_id

Given the $object_id (and a WP_Term object), how does one go about determining the $meta_type to be passed to update_metadata()? Unfortunately, that is not possible because each object has its own table and therefore the same ID (1, 2, 3, etc.) could refer to a post, comment, term, etc. So that’s why we have different … Read more

Get Comma Seperated Taxonomy Linked Terms and Last Child Separated By “&” Instead Of Comma

What you’re asking is a generic PHP/programming question, and this: “It links all terms to the last term link only“, is because your code clearly is attaching the link (i.e. the last value assigned to $term_link) to the entire list ($entry_terms), i.e. echo ‘<a href=”‘ . esc_url( $term_link ) . ‘”>’ . $entry_terms . ‘</a>’. … Read more

Set term on an attachment using wp_set_object_terms and want to display the full term text but it’s showing a slug instead

When a visitor fills out the email address field with “[email protected]”, what is displayed on the Attachment details screen (as in siteurl.com/wp-admin/upload.php?item=xx ) for that email field is “nameemail-com”. Yes, and that is the default behavior, i.e. WordPress displays the term slug instead of name (or the actual email address in your case). But there’s … Read more

For each loop on every word in post

Are you sure you want to link every instance of each ingredient? As a user, I wouldn’t mind if the ingredient list above the recipe had all its ingredients linked, but if the following instructions continued linking every ingredient I’d find that to be a lot of links I could accidentally tap on and lose … Read more

Get_the_terms restrict output

you can change you code a bit : $taxonomy = ‘country’; $terms=get_the_terms($post->ID,$taxonomy); if($terms) { echo ‘<h1>Holiday ‘; $total_count = count($terms); $country_count = 1; foreach( $terms as $termcountry ) { if ($country_count = 1){ echo ‘in ‘.$termcountry->name; }else{ if ($total_count = 2){ echo ‘ And ‘.$termcountry->name; }else{ echo ‘, ‘.$termcountry->name; } } $country_count = $country_count + … Read more