Custom Taxonomy with Custom Post Type Finds No Posts

I don’t know how or why, but this code below solved by issue. Seems to me like I shouldn’t need it, but apparently I do. add_filter(‘pre_get_posts’, array(&$this, ‘modify_pre_query_request’)); public function modify_pre_query_request($query){ if ($query->is_main_query()){ if ($query->is_tax){ $post_type = get_query_var(‘post_type’); if (!$post_type){ $post_type = array( ‘post’, ‘YOUR POST TYPE’ ); $query->set(‘post_type’, $post_type); } } } } Keep … Read more

Exclude specific slug in ‘get_terms’

The get_terms() (see docs) function accepts the same args as WP_Term_Query(see docs) You have to get those terms Ids first and then pass it to the exclude arg: // default to not exclude terms $ids_to_exclude = array(); $get_terms_to_exclude = get_terms( array( ‘fields’ => ‘ids’, ‘slug’ => array( ‘graduate’, ‘job-market-candidate’, ‘graduate-student’, ‘research’ ), ‘taxonomy’ => ‘role’, … Read more

wp_set_object_terms() is not replacing term, but creating a new one

In both the cases issue is not the other things, but the main value what you are sending to the second parameter, in your case $flightCategory: $flightCategory = array( 25 ); var_dump( $flightCategory ); wp_set_object_terms( $post_id, $flightCategory, ‘flight_categories’ ); But on the later version somehow, or literally you are actually passing something like below: $flightCategory … Read more