List taxonomy term slugs within shortcode (do_shortcode)

The do_shortcode() function is currently in the foreach loop. I don’t know what are the parameters of this shortcode , but if it accepts comma separated values of term slugs: $terms = get_the_terms( $post->ID , ‘shoptype’ ); $i=1; $commaSeparatedvalues=””; foreach ( $terms as $term ) { $term_link = get_term_link( $term, ‘shoptype’ ); if( is_wp_error( $term_link … Read more

Add Taxonomy Description with wp_set_post_terms

You can’t use wp_set_post_terms() to set the term description, but you can use wp_insert_term() to create the term and set the description (plus other details), and then pass the term ID to wp_set_post_terms(). Working example for one term: $taxonomy = ‘category’; $term_name=”Foo Bar”; // First we create the term (if it doesn’t already exist). if … Read more

Can anybody provide me with a function to generate slugs?

This post provides a function, but it cannot handle non-latin characters. That’s because URLs can’t have non-latin/ASCII characters. Browsers might show non-latin characters to you, but it’s just a user interface feature. For example, if you visit this Wiktionary URL: https://en.wiktionary.org/wiki/わかもの#Japanese, you browser URL encodes the japanese characters to get the real URL: https://en.wiktionary.org/wiki/%E3%82%8F%E3%81%8B%E3%82%82%E3%81%AE#Japanese then … Read more

Leveled – Terms foreach

Why not use wp_list_categories( ‘taxonomy=section’ ) ? It’ll do all the nesting & hard work for you! If you want more control over the HTML output, implement a custom walker.

wp_set_object_terms not working inside loop

You can pass an array of terms to wp_set_object_terms, there is no need for the for each: $genres= array(‘action’, ‘comedy’, ‘horror’); $ret = wp_set_object_terms( $postId, $genres, ‘genres’);

A mandatory agreement form to access another page?

I would use a shortcode for this. Wrap the content you want behind the “terms_required” shortcode, if the user hasn’t agreed to the terms, show them the form. The form would submit to a custom rewrite rule (url endpoint) that validates the form and sets a cookie if everything checks out. Let’s start by wrapping … Read more