Weekdays as terms – How to order taxonomy terms by ID in admin panel?

Method #1 – Modifying the query arguments If we want to modify the term order for the schedule_day_taxonomy term checklist, on the single schedule cpt edit screen, then we can use the following setup: add_action( ‘load-post.php’, function() { add_filter( ‘wp_terms_checklist_args’, ‘wpse_terms_checklist_args’ ); } ); function wpse_terms_checklist_args( $args ) { // Target the ‘schedule’ custom post … Read more

term_exists() returning NULL on term that exists

The third argument for term_exists() is an integer, not an array. Parameters $term (integer|string) (required) The term to check Default: None $taxonomy (string) (optional) The taxonomy name to use Default: ” $parent (integer) (optional) $parent ID of parent term under which to confine the exists search Default: 0 Pass the correct arguments and it works. … Read more

Post with certain term and without any term

This should be possible with the tax_query parameters for WP_Query. The query is either for posts where any term NOT EXISTS, OR, for any posts where the term IDs are IN the provided array. ‘tax_query’ => array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘group’, ‘operator’ => ‘NOT EXISTS’, ), array( ‘taxonomy’ => ‘group’, ‘field’ => … Read more

wp_insert_post() does not support variable

There is no difference in PHP between a string and a variable set to a string, so the problem is elsewhere. Most likely it is with passing the slug argument as mentioned in the codex for wp_insert_term: https://codex.wordpress.org/Function_Reference/wp_insert_term : If ‘slug’ argument exists then the slug will be checked to see if it is not … Read more

Limit Taxonomy Output in Conditional Statement

Samuel Elh correctly answered this. if ( $type === ‘portfolio’ ) { $terms = get_the_term_list( $post->ID, ‘royal_portfolio_cats’, ”, $separator ); $term_array = explode(‘,’,$terms); if ( $limit = array_slice($term_array, 0, $max = 5) ) { echo implode( “, “, $limit ); if ( count( $term_array ) > $max ) { echo “…”; } }; }