List taxonomy terms plus their latest post ordered by post date

Right now you are performing the query by term, and displaying results instantly. What you need is to gather the results of each query, sort them and then display separately. Make sure to read code comments. /* $custom_terms = get_terms(‘columna’); – this approach is depreciated */ $custom_terms = get_terms( array( ‘taxonomy’ => ‘columna’ ) ); … Read more

Contact Form 7 – Populating dropdown list with terms relative to the post

Use the dynamic_dropdown tag functionality offered by the Smart Grid layout extension. The dynamic tag can take 3 sources of data (a given taxonomy, or branch within that taxonomy, a list of post titles, or the results of a filtered hook function). Use the filter hook to populated your dropdown as, add_filter(‘cf7sg_dynamic_dropdown_custom_options’, ‘filter_options’,10,3); function filter_options($options, … Read more

Separator for multiple terms

If you need just the term names, fetch just the term names: use the field parameter for get_terms(). Build a comma separated list with an and between the last two items with wp_sprintf_l(). // get the term names $term_names = get_terms( ‘department’, array ( ‘fields’ => ‘names’ ) ); // glue the names with comma … Read more

Display Custom Taxonomy Terns ordered by meta_value

Assuming the position field is filled with numbers to give order: have a look at ksort. <?php $terms = get_terms(‘brands’); // Let’s create our own array and then reorder it $order_terms = array(); foreach( $terms as $term ) { $position = set_up_the_position_meta_here; $order_terms[$position] ='<h2>’.$term->name.'</h2>’; } // now lets reorder the array based on keys (position) … Read more

Missing term_id and term_taxonomy_id when adding a term using wp_insert_term() function

The problem is the use of the php function list. If successful, wp_insert_term returns something of the form: array(2) { [“term_id”]=> int(307) [“term_taxonomy_id”]=> int(325) } You can’t use list with this as list only works for numerical arrays. Instead try extract instead: extract($result); echo “<p>The term <i>{$term_name}</i> under the <i>{$term_taxonomy}</i> taxonomy has been added into … Read more

category not display in word press grammatically

Where are you calling this code? You need to add it to one of the init hooks. If I add that to either a plugin or theme init, then it adds just fine for me, with the $slug typo corrected as Mike pointed out. echo ‘<p>Debug: Loaded functions.php</p>’; function yourtheme_init() { echo ‘<p>Debug: called yourtheme_init</p>’; … Read more

wp_update_term not creating new unique slug

I think you are running into trouble with these lines in wp_update_term(): 3287 // Merge old and new args with new args overwriting old ones. 3288 $args = array_merge($term, $args); https://core.trac.wordpress.org/browser/tags/4.1.1/src/wp-includes/taxonomy.php#L3287 The array passed in gets merged with the data already in the DB. Set your slug explicitly: $nname=”my new name”; wp_update_term( 10, ‘artists’, array( … Read more

Get used terms by an author as array of strings

I don’t know which line that error refers to but this code works correctly if everything falls into place exactly right. But there are actually several ways this could go wrong. For example, if get_query_var(‘author_name’) is not set you get an error on this line: $used_terms=list_author_used_terms($user->ID); If a problem occurs here: $terms = wp_get_object_terms( $p->ID, … Read more