Get post by term from custom taxonomy in another blog on the network?

I found a small hack to filter by taxonomy without create the taxonomy in the child theme. In the core exists the function “taxonomy_exists“: function taxonomy_exists( $taxonomy ) { global $wp_taxonomies; return isset( $wp_taxonomies[$taxonomy] ); } And is this function who hive “false” because the taxonomy don’t exists in your child theme. If this function … Read more

get_terms function not returning anything

get_terms just returns an array of terms, it doesn’t generate output. You have to do something with that array to see the results- $categories = get_terms( “category” ); echo “<ul>”; foreach ( $categories as $category ) { echo “<li>” . $category->name . “</li>”; } echo “</ul>”; See the other examples on the Codex page.

How to add terms (without deleting others)

The fourth parameter to wp_set_object_terms() is an “append” argument. $append (bool) (required) If true, tags will be appended to the object. If false, tags will replace existing tags Default: False http://codex.wordpress.org/Function_Reference/wp_set_object_terms Your code should work if you pass true as that fourth argument. wp_set_object_terms( $post->ID, explode( ‘,’, $_POST[‘postTags’] ), ‘product_tag’, true );

Get Custom Taxonomy Terms by Date

This is the working code: // latest edition $taxonomies = array( ‘jjm_editions’ ); $args = array( ‘orderby’ => ‘ID’, ‘order’ => ‘DESC’, ‘hide_empty’ => false, ‘number’ => ‘1’ ); $terms = get_terms($taxonomies, $args); foreach ( $terms as $term ) { $term_link = get_term_link( $term ); if ( is_wp_error( $term_link ) ) { continue; } echo … Read more

How to get a post’s associated taxonomies and terms in wp api v2

Ok, I just stumbled upon the answer buried deep in the github issues page: https://github.com/WP-API/WP-API/issues/1403 The answer is: the reason is that the terms / meta etc are different objects, and in typical REST design going a GET on a single resource, will give you that resource, not that resource and a bunch of other … Read more

Print current post category during WP_Query

You are using the get_the_terms() but this function is used to get the custom taxonomies. Use the function get_the_category(); inside the WordPress loop and pass the get_the_ID() function which will get the current post ID in the loop. get_the_category(get_the_ID()); <?php $args = array( ‘post_type’ => ‘work’, ‘posts_per_page’ => ‘9’ ); $work_loop = new WP_Query( $args … Read more

the_terms characters not limiting

This is not working because the_terms() is echo-ing the output. It would make more sense to trim down the lengthy term names, instead of doing it directly on the HTML output of get_the_term_list() that’s used by get_the_terms(). That could give unvalid HTML, that could break the layout of your site. Here’s an example for the … Read more