Exclude a specific tag from the get_the_tags list

$tags = get_the_tags( $post->ID ); $separator=” “; $output=””; if($tags){ echo ‘<div class=”entry-tags”>’; echo “<p><span>” . __(‘Tags’, ‘tracks’) . “</span>”; foreach($tags as $tag) { // dpm($tag) here by uncomment you can check tag slug which you want to exclude if($tag->slug != “yourtag”){ // replace yourtag with you required tag name $output .= ‘<a href=”‘.get_tag_link( $tag->term_id ).'” … Read more

Special characters in tag get removed for comparison on save

Basically, when you add a new term, WordPress will use term_exists() to validate term before add it to database. term_exists() uses sanitize_title() which uses remove_accents() and sanitize_title_with_dashes() to sanitize term. remove_accents() will converts all accent characters to ASCII characters and sanitize_title_with_dashes() will limits the output to alphanumeric characters, underscore (_) and dash (-), whitespaces will … Read more

How to use meta data for each tag cloud a

WordPress outputs a handy class name for each tag cloud link using the format .tag-link-{term_id}. This will allow us to target each term by its id. This code will generate styles for term links output by the tag widget: add_action( ‘wp_head’, ‘wpse_tag_colors’ ); function wpse_tag_colors() { $terms = get_terms( [ ‘taxonomy’ => ‘category’, ‘hide_empty’ => … Read more

Individual css class for each tag in wp_tag_cloud

try this code: add_filter ( ‘wp_tag_cloud’, ‘tag_cloud_font_size_class’ ); function tag_cloud_font_size_class( $taglinks ) { $tags = explode(‘</a>’, $taglinks); $regex1 = “#(.*style=”font-size:)(.*)((pt|px|em|pc|%);”.*)#e”; $regex2 = “#(style=”font-size:)(.*)((pt|px|em|pc|%);”)#e”; $regex3 = “#(.*class=”)(.*)(” title.*)#e”; foreach( $tags as $tag ) { $size = preg_replace($regex1, “(”.round($2).”)”, $tag ); //get the rounded font size $tag = preg_replace($regex2, “(”)”, $tag ); //remove the inline font-size style … Read more

Change the color of post title on specific tags

I’m not aware of any way to do this without editing code. I wrote a PHP function which will wrap your post titles in a with the class “hastag-{tag-slug}”. You can put this in your theme’s functions.php file and then use the_title_with_tags() instead of the_title() in your theme templates. function the_title_with_tags() { //get all tags … Read more

Why ‘C++’ tag is converted to ‘C# ‘?

I can duplicate this behavior. Probably a bug. Only alphanumeric characters and dashes are allowed in tag slugs, so my slugs for C++ and C# were created as “c” and “c-2,” respectively. Adding these tags to a new post by name rather than slug lumped them all into C#. (Or was it C++? Either way, … Read more

Tags as a dropdown with set tags

You can use wp_dropdown_categories() to create your dropdown: wp_dropdown_categories(array(‘taxonomy’=> ‘post_tag’,’hide_empty’ => 0, ‘name’ => ‘my_tags’)); Update the reason you are getting the term ID is because wp_dropdown_categories sets the ID’s as values so instead of just echo’ing it out you need to get the term, something like: $term = get_term_by(‘id’,$your_id,’post_tag’); echo $term->name;

get_terms with more than x post count

Give: $terms = get_terms(“my_taxonomy”); $count = count($terms); if ( $count > 0 ){ echo “<ul>”; foreach ( $terms as $term ) { if ($term->count > 2) { echo “<li>” . $term->name . “</li>”; } } echo “</ul>”; } a shot. It will grab all the terms and then run a check to see if the … Read more