Tag Info

New answers tagged

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 ...


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 ...


0

From your comments, you opted for a custom page template. Based on that, you can simply perform a custom query to retrieve posts that belongs to a certain tag and category I tend to make use of a tax_query using WP_Query when you quering posts from more than one taxonomy. It is more flexible, specially if you need to exclude children from hierarchical ...


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

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 ...


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( ...


0

Thanks to Mark, I solve this successfully. Update: Thanks to Kaiser part of the code has been updated. Here is the final code. <?php $custom_terms = get_the_terms(0,'product_tag'); if ( ! is_wp_error( $custom_terms ) AND is_array( $custom_terms ) AND ! empty( $custom_terms ) ) { foreach ...


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 ...


0

Let's not fool ourselves here guys. The accepted answer only got the user to his goal. The very first problem lies here: <?php // display upsells and related products within dedicated div with different column and number of products remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products',20); remove_action( ...


0

If all you're looking to do is list out the model tags as list items, this should work for you: $terms = get_the_terms( $post->ID, 'model_tag' ); if ( $terms && ! is_wp_error( $terms ) ) : $model_tags = '<ul>'; foreach ( $terms as $term ) { $model_tags .= '<li>' . $term->name . '</li>'; } $model_tags ...


0

TinyMCE is programmed to make editing easy (which for us HTML savvy is often not the case). By default is should not accept <p> tagging around [BLOCKS]. That is because "[]" are used for shortcode not only in WP but a ton of PHP based CMSs. The shortcodes should have the appropriate content wrapper. Meaning the solution is to add the <p> ...



Top 50 recent answers are included