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

Set homepage to only display posts from one tag

You should use pre_get_posts to alter the main query on the home page. With the proper conditional tags and parameters (check WP_Query for available parameters) you can achieve what you need You can do the following to just display posts from a given tag on your homepage add_action( ‘pre_get_posts’, function ( $query ) { if … Read more

Link directly to the first post in an archive

try this ( untested and assuming of course that $tag is the right object tag and $tag[‘count’] is the number of post with that tag ): if ( $tag[‘count’] > 1 ) { //first part of your code } else if($tag[‘count’] == 1){ $the_query = new WP_Query( ‘tag=’.$tag[‘name’] ); if ( $the_query->have_posts() ) { while … Read more

How to add class on term link?

I think you should use a custom loop: <?php $terms = get_the_terms( $post->ID, ‘product_tag’ ); if ($terms && ! is_wp_error($terms)): ?> <?php foreach($terms as $term): ?> <a href=”https://wordpress.stackexchange.com/questions/130622/<?php echo get_term_link( $term->slug,”product_tag’); ?>” rel=”tag” class=”<?php echo $term->slug; ?>”><?php echo $term->name; ?></a> <?php endforeach; ?> <?php endif; ?>

WP API Get post with tag names instead of tag ID’s

I figured something out based on what I found at this post. Basically I need a plugin that listens for when the REST response is about to go out. The plugin code would be similar to the following: function ag_filter_post_json($response, $post, $context) { $tags = wp_get_post_tags($post->ID); $response->data[‘tag_names’] = []; foreach ($tags as $tag) { $response->data[‘tag_names’][] … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)