Odd results in get_the_terms vs wp_get_post_terms

The primary difference between the two is that wp_get_post_terms is not cached and always goes straight to the database, in fact get_the_terms uses the same API internally, wp_get_post_terms is a wrapper around wp_get_object_terms, which is also used by get_the_terms but with caching and fewer configurable options. However, this is an X Y question. You shouldn’t … Read more

Properly setting up a feed

Feed links have to use the category slug (not the name) (“Blog-Artikel” –> “blogpost” in the case of the site in question) Feed links have to conform with the localization of the page offering the feed (i.e. “category” –> “kategorie” for a WP site with a Germain domain. Funny enough, the WP site language of … Read more

How to change the order of the subcategory and category in a post?

You can write a get_the_terms filter to change the other the category values are returned, e.g. function sort_the_terms( $terms, $post_id, $taxonomy ) { if ( ‘categories’ === $taxonomy ) { usort( $terms, function( $term1, $term2 ) { // Better sort logic here return $term1->name <=> $term2->name; } ); } return $terms; } add_filter( ‘get_the_terms’, ‘sort_the_terms’, … Read more

Change the name Category – Not change category name

Use taxonomy_labels_category filter (documented here: https://developer.wordpress.org/reference/hooks/taxonomy_labels_taxonomy/) in order to change any of the labels that you need changed. Here’s what works for me: add_filter( ‘taxonomy_labels_category’, ‘filter_category_labels’ ); function filter_category_labels( $labels ) { $labels->menu_name=”Jurisdiction”; return $labels; } You will have to change quite a few other values in the $labels object though. Here’s a full list … 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