Problem:
The issue here is that the user wanted to count the number of terms that is attached to a post.
Solution:
// Add Shortcode function count_post_terms( $atts ) { // Attributes $atts = shortcode_atts( array( 'post_id' => '', 'taxonomy' => '', ), $atts ); $terms = wp_get_post_terms( $atts['post_id'], $atts['taxonomy']); return count($terms); } add_shortcode( 'count_post_terms', 'count_post_terms' );
Add the shortcode above to your functions.php file and you can use this shortcode [count_post_terms] to count the terms attached to a post.
The exact example is.
1
[count_post_terms post_id='[wpv-post-id]' taxonomy='category']
In order to use this in our views conditional shortcode you need to add it to our views 3rd party shortcode arguments in Toolset->Settings->Frontend Content.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
Este tema contiene 2 respuestas, tiene 2 mensajes.
Última actualización por hace 6 años, 4 meses.
Asistido por: Shane.