Skip Navigation

[Resolved] documentation error

This support ticket is created 5 years ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 5 years ago.

Assisted by: Nigel.

Author
Posts
#1406765

https://toolset.com/documentation/adding-custom-code/how-to-create-a-custom-shortcode/

A very small issue but slightly confusing:

Sample code and Sample Shortcode don't match

 // Add Shortcode
function myprefix_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( 'myprefix_count_post_terms', 'myprefix_count_post_terms' ); 
 [count_post_terms post_id='[wpv-post-id]' taxonomy='category'] 

Should be

 [myprefix_count_post_terms post_id='[wpv-post-id]' taxonomy='category'] 
#1407065

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Bryan

Thanks for pointing that out. I've passed the info on to the documentation team, who are fixing it as I type.