Tag Info

Hot answers tagged

2

Keep in mind that the return value of get_the_terms() can be of the type of array|WP_Error Your snippet should check if you get the correct type returned $terms = get_the_terms( 0, 'product_tag' ); if ( ! is_wp_error( $terms ) AND is_array( $terms ) AND ! empty( $terms ) ) { foreach( $terms as $term ) printf( ...


2

It's a lot easier to create a new WP_Query than it is to try clearing or overwriting the original. If $post_tag is a tag slug, you could simply use: <?php $the_query = new WP_Query( 'tag='.$post_tag ); if ( $the_query->have_posts() ) { echo '<ul>'; while ( $the_query->have_posts() ) { $the_query->the_post(); echo ...


2

To show post excerpts on my tags page, you will need to make changes in content.php. By default content.php uses post excerpts for search pages only but you can modify the default behavior. This is how you can include tag pages to show post excerpts. Add || is_tag() as follows: <?php if ( is_search() || is_tag() ) : ?> <div ...


1

We can modify the output with the filters wp_tag_cloud or wp_generate_tag_cloud. But we could also use: echo strip_tags( wp_tag_cloud( 'echo=0&smallest=10&largest=10&number=0&format=list' ), '<ul><li>' ); where we strip all the HTML tags from the output, except the ul and li tags. Notice that we added the echo=0 ...


1

Look at has_tag(). It seems that is what you are looking for You can use it like follow if( has_tag( 'NAME OF TAG' ) ) { // do something if has tag }else{ // do something else if not have tag }


1

Run a couple of queries and a code snippet to calculate the word count for the post content, comments content and tag names on each post. // This query will return the number of words in the post content $post_qry="SELECT LENGTH(post_content) - LENGTH(REPLACE(post_content, ' ', ''))+1 from wp_posts where ID=".$post_id; // This query will return the number ...



Only top voted, non community-wiki answers of a minimum length are eligible