I created a repeating custom term field - file type - and try to display file title with link on a category page.
I try the following code:
[wpv-for-each termmeta="wpcf-ctg-files"]
[my_file_name file_url='[types termmeta="ctg-file" output="raw"][/types]']<br />
[/wpv-for-each]
... but unfortunately not work.
Please help me. Thanks
PS: i created a shortcode:
add_shortcode( 'my_file_name', 'my_file_name_func');
function my_file_name_func($atts) {
$urls = $atts['file_url'];
$fileparts = explode('/', $urls);
return end($fileparts);
}
The shortcode and wpv-for-each works well on custom field
PS: i created a shortcode:
add_shortcode( 'my_file_name', 'my_file_name_func');
function my_file_name_func($atts) {
$urls = $atts['file_url'];
$fileparts = explode('/', $urls);
return end($fileparts);
}
The shortcode and wpv-for-each works well on custom field
Hello and thank you for contacting the Toolset support.
The code that you shared seems correct to me, I don't see what's causing the issue. Would you like to reproduce this issue in one of our test sites and let me check it? If yes, you can log in to this test site using the following URL hidden link
As soon as the issue is reproduced, I'll log into the site and see what's causing the issue.
Hi Jamal,
I configured a custom term group with a custom filed - files type and choos repeat - and i added to post category. After that i create a new archive template for post categories archive. Also i added the shortcode "my_file_name" and custom code for it.
I add 5 pdf file to category named "Test-Ctg-for-custom-repeating-field". The result display only 1 attachment, not 5 => hidden link
Thank you!
Thank you!
I checked this with our 2nd Tier and he confirms that the wpv-for-each shortcode is meant to be used with posts and will not work with terms or users. So I built a custom shortcode that does the job:
add_shortcode( 'term_files', 'my_term_files_func' );
function my_term_files_func($atts){
$atts = shortcode_atts( array(
'field' => '',
), $atts );
$field = $atts['field'];
if ( ! $field ) return;
$values = get_term_meta( get_queried_object_id(), $field, false );
$out = "";
foreach( $values as $value ){
$out .= '<a href="' . $value . '" target="_blank">' . end( explode( '/', $value ) ) . '</a><br />';
}
return $out;
}
To be used like:
[term_files field="wpcf-tfrf"]
Check the results here hidden link
hidden link
My issue is resolved now. Thank you!