Get X post tags

Your question seems similar to this one: how to limit and display tag? Based on it you can use this code to limit the tags: $post_tags = get_the_tags(); shuffle($post_tags); // use this incase you want to pick the tags randomly $count = 0; if ($post_tags) { foreach($post_tags as $tag) { $count++; echo ‘<a href=”‘.get_tag_link($tag->term_id).'”>’.$tag->name.'</a> ‘; … Read more

Replace -tag in the_excerpt

You should try this: function replace_tag($string){ $search = array(‘<p>’, ‘</p>’); $replace = array(‘<h2>’, ‘</h2>’); echo str_replace($search, $replace, $string); return $string; } add_filter(‘the_excerpt’, ‘replace_tag’); or this: function replace_tag($string){ $replace = array( ‘<p>’ => ‘<h2>’, ‘</p>’ => ‘</h2>’ ); $string = str_replace(array_keys($replace), $replace, $string); return $string; } add_filter(‘the_excerpt’, ‘replace_tag’);

How to test if the tag list is empty for the current page?

You can use wp_get_post_terms() function, like this: if ( wp_get_post_terms( $post->ID, ‘topic’, [ ‘fields’ => ‘ids’ ] ) ) { // Your code } We passed the ‘fields’ => ‘ids’ in args, just to prevent instantiation of the full WP_Term objects in the background, since you only need to check if there are any, and … Read more

Display text if title in archive has specific word

You may use string comparison. I could illustrate a simple example code. It is assumed that the user with the following knowledge/experience PHP – understand what is variables, static value WordPress templates and how to modify them There are many ways to test string such as php string comparison strpos() (simple) php regular expression preg_match() … Read more

Get the publish date of the older post inside a tag

To get the publish date to each post via the template tag get_the_date(). However, this works only inside the Loop. I’m understanding what you mean with ‘inside current tag’. But the tag is an additional meta value to the post type, via taxonomy and is without dependent to the post date.

How remove tags just have one post?

I found the sql code and It works fine. I just change 0 to 1 DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE count = 0 );

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