Skip Navigation

[Closed] Count the number of attached files in the file field repeater.

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 -
- - - - - - -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 7 replies, has 3 voices.

Last updated by Adriano 9 years, 7 months ago.

Assisted by: Adriano.

Author
Posts
#239823

I would like to add in my post the amount of attached files, but only attached by types file field.

#240032

Dear Angelo Rocha,

Try use this code:
1. Add this to theme/functions.php

add_shortcode('show_repetitive_count','show_repetitive_count_func');
function show_repetitive_count_func($atts){
	$atts = shortcode_atts( array(
 	      'post' => 0,
 	      'field' => ''
      ), $atts );
	if ( empty($atts['post']) || empty($atts['field']) ){
		return;	
	}
	$count = types_render_field( $atts['field'], array("id" => $atts['post'], 'separator' => ',') );
	$count = explode(',',$count);
	return count($count);
}

Usage: [show_repetitive_count post="POSTID" field="FIELDNAME"]
example: [show_repetitive_count post="69" field="my-numeric"]

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Regards,
Gen.

#240270

How would without shortcode?
I would put the counter in my theme, with php.

#240323

Dear Angelo Rocha,

Use same function and add this code

$total = show_repetitive_count_func( array('post' => 1, 'field' => 'my-field') );

Don't forget change post id and field name.

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Regards,
Gen.

#240346

Hi, thanks for your help.
It worked, but is still counting the featured image.
I would like count only the types file field.

#240398

Dear Angelo Rocha,

Just change 'field' => 'my-field',
my-field to your repetitive field slug.

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Regards,
Gen.

#240404

I make this change. But this code count the featured image as a file field. Sorry for my bad english, i do not know if i'm explaining right.

#240679

Ghennadi is not available to handle this issue anymore, I will. I need to request temporary access (wp-admin and FTP) to your site in order to be of better help. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

The topic ‘[Closed] Count the number of attached files in the file field repeater.’ is closed to new replies.