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 “…”; } }; }

Add class to first post queried

<?php $_terms = get_terms( array(‘claim-accordion-type’) ); $i = 0; foreach ($_terms as $term) : $term_slug = $term->slug; $_posts = new WP_Query( array( ‘post_type’ => ‘claims_accordion’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘claim-accordion-type’, ‘field’ => ‘slug’, ‘terms’ => $term_slug, ), ), )); if( $_posts->have_posts() ) : $i++; if ( $i == 1 ) … Read more

Category archive in with conjunction with custom post type is empty

WordPress only includes the post post type for Category archives by default, but you can add additional post types by altering the query: function wpse241719_add_custom_types_to_category_archives( $query ) { if ( ! is_admin() && is_category() && $query->is_main_query() ) { $query->set( ‘post_type’, array( ‘post’, ‘work’, // ‘another_post_type’, ) ); } } add_filter( ‘pre_get_posts’, ‘wpse241719_add_custom_types_to_category_archives’ );

Having Issue on Passing Variable into HTML Class Tag

Right, that’s because “get_the_term_list” returns an html string of tags… Those won’t work well as class attributes! : ) I suspect what you want is wp_get_post_terms instead: $terms = wp_get_post_terms( get_the_ID(), ‘type’, array(‘fields’ => ‘slugs’) ); // array of term slugs echo ‘<div class=”element-item’.implode(‘ ‘, $terms).'”>’; Hope this helps!

Update table wp_term_taxonomy.count after INSERT INTO via SQL

You can just run the wp_update_term_count_now php function after doing this: https://developer.wordpress.org/reference/functions/wp_update_term_count_now/ Which calls the private _update_post_term_count https://developer.wordpress.org/reference/functions/_update_post_term_count/ If you look at the source of that you will see how term counts are updated (which is done when you save a post on backend): function _update_post_term_count( $terms, $taxonomy ) { global $wpdb; $object_types = (array) … Read more