Do tags have dates?

Following @PieterGoosen’s (credit due) train of thought hook onto the following: function update_term_timestamps($term_id) { switch( current_filter() ) { case ‘created_term’: update_term_meta($term_id, ‘_term_created_at’, current_time(‘mysql’, true)); break; case ‘edited_term’: update_term_meta($term_id, ‘_term_edited_at’, current_time(‘mysql’, true)); break; } } add_action(‘created_term’, ‘update_term_timestamps’); add_action(‘edited_term’, ‘update_term_timestamps’); Now the meta data is accessible with: //for created timestamp… $timestamp = get_term_meta($term_id, ‘_term_created_at’, true); //for edited … Read more

Check if current page has given tag ID

All the tags is inside the query, it is possible to check for this via get_query_var(); all objects inside the query. For the tag ID ask with this code: get_query_var( ‘tag_ID’ ); Also it is possible to check for tags, like get_query_var( ‘term’ ) and the taxonomy get_query_var( ‘taxonomy’ ) So you can create an … Read more

Display list of most used tags in the last 30 days

The problem was that the SQL query code was getting the term_taxonomy_id, not the actual tag ID. I added an additional INNER JOIN using the term_taxonomy table to get the term_id. This seems to work, but if a mod can improve this, please do! <ul id=”footer-tags”> <?php $wpdb->show_errors(); ?> <?php global $wpdb; $term_ids = $wpdb->get_col(” … Read more

How do I display a tag cloud under my post that only shows tags from that post?

First you need to get all the assigned tag id:s by calling wp_get_post_tags because the include parameter in wp_tag_cloud only works with tags id, Not page id. So when you have all the id:s put them in the include parameter within the wp_tag_cloud like this: <?php // Get the assigned tag_id $tag_ids = wp_get_post_tags( $post->ID, … Read more

How to Get Next or Previous Post in a Specific Tag?

get_adjacent_post(), which is used by all functions that return a (link to) the next or previous post, only has a $in_same_cat argument, which looks at the categories the post is in, not the tags. You could hook into the get_[next|previous]_post_join to modify the join query for your call, but then it’s probably easier to copy … Read more

Order tags, but not alphabetically

One way to do it is to store the order of the tags as post meta data, using the action set_object_terms which happens to pass the tags in the order they appear on edit, eg in your “functions.php”: // Called in admin on updating terms – update our order meta. add_action( ‘set_object_terms’, function ( $object_id, … Read more

Why is wp_kses not keeping style attributes as expected?

This is an older question, but here’s the answer for future generations: WordPress will check the styles against a list of allowed properties and it will still strip the style attribute if none of the styles are safe. The default allow list is: text-align margin color float border background background-color border-bottom border-bottom-color border-bottom-style border-bottom-width border-collapse … Read more