Tell us what you are trying to do?
I'm trying to create an easy to use method for a client to load a pdf document into the media library, add a title/cover image, and see the title/cover image as the link on the front end in the page.
I updated the Child: functions.php with the following code that I found:
/**
* Function to get the title from the pdf document
*/
add_shortcode( 'my_file_name', 'my_file_name_func'); // Actually activate the shortcode
function my_file_name_pdf_func($atts) {
global $post; // So we can get the post meta later on
$res = ''; // Setting up a variable to hold the links so we can return it later
$types = $atts['field'];
if ($types) { // if the types_field argument was provided
//define ShortCode attr prefix
$types = "wpcf-$types";
$urls = get_post_meta($post->ID,$types); // let's get the (potentially multiple) values
if(empty($urls[0])){
return;
}
$arr = array();
foreach ($urls as $fileurl) { // Let's iterate for each of the multiple values
$id = pippin_get_image_id($fileurl);
$title = get_the_title($id);
$arr[] = '' . $title . ''; // Create whatever HTML and store it in the $content variable
}
$res = implode(' | ', $arr);
}
return $res; // Return the content as the shortcode value
}
But then I don't know how to integrate the shortcode value in the view that I'm working on. I added it under "Field Settings" > Optput mode > File link tile "my_file_name" but it is not working 🙁 (Probably I'm doing something really wrong - but I don't know how to call this shortcode under this view) - Image attached.
Is there any documentation that you are following?
Yes, the one from here: https://toolset.com/forums/topic/displaying-file-title-with-a-link-for-custom-field-for-manuals-etc/
Is there a similar example that we can see?
Yes, here is the link:
hidden link
What is the link to your site?
hidden link