List all custom post type posts from a given category?

What about doing a tax_query? $args = array( ‘post_type’ => ‘myposttype’, ‘tax_query’=> array(         ‘taxonomy’ => ‘myposttype_categories’,         ‘terms’ => array(‘foo’),         ‘field’ => ‘slug’,     ) ); $loop = new WP_Query( $args ); var_dump($loop); Facepalm question, you are sure that these taxonomies/post types exist and that there are posts filed under them? Update The query seems to work … Read more

tax_query: What to pass when I want to have all terms?

Simply omit (or not add) tax_query part of arguments. $args = array( ‘post_type’ => ‘wr_event’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘event_date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => $order, ‘meta_value’ => $yesterday, ‘meta_compare’ => $compare, ); if ( ! is_null($cat) ) $args[‘tax_query’] =array( array( ‘taxonomy’ => ‘event_type’, ‘field’ => ‘slug’, ‘terms’ => $cat, ‘operator’ => ‘IN’ ), … Read more

Get Term names from WP Term Object

Here’s an alternative using the handy wp_list_pluck(): $terms = get_terms(array( ‘taxonomy’ => ‘category’, ‘hide_empty’ => false, )); $slugs = wp_list_pluck( $terms, ‘slug’ ); $names = wp_list_pluck( $terms, ‘name’ ); where we pluck out the wanted field into an array.

How to Get All Taxonomies AND All Terms For Each Taxonomy With Post Count Zero

You can do this with just get_terms – this allows you to fetch all (or some) of the terms from one (or more) taxonomies. By default it excludes ’empty’ terms, so you’ll need to set the arguments appropriately. //Array of taxonomies to get terms for $taxonomies = array(‘category’,’post_tags’,’my-tax’); //Set arguments – don’t ‘hide’ empty terms. … Read more

how is it possible that using wp_insert_category throw a fatal error?

The init action is the wrong place. This is because init runs on all requests, admin or front-end, but the wp_insert_category function is an admin-side only function. You generally don’t insert categories from the front end. Move to a more specific action, one that will be run in the admin side. Probably from your plugin’s … Read more

Wp set post terms not work

As stated in the wp_set_post_terms Comment: This function will only work on the native post type. For a taxonomy on a custom post type use wp_set_object_terms() wp_set_object_terms

How can I remove links from the function “get term list”?

It may be easier to just write the list manually, something like: <?php $terms = wp_get_post_tags( $post->ID ); //For custom taxonomy use this line below //$terms = wp_get_object_terms( $post->ID, ‘people’ ); foreach( $terms as $term ) $term_names[] = $term->name; echo implode( ‘, ‘, $term_names );