I want to display only the filename (not the full URL) from a Toolset file field using a shortcode and also show a message if there are no files.
Solution:
Create a custom shortcode using PHP to extract the filename with basename($url), then use Toolset’s [wpv-conditional] shortcode to check if the field has content and show either the filenames or a fallback message.
I am trying to retrieve the post ID of a related post connected through a specific Toolset Post Reference Field in PHP, but using get_post_meta() returns an empty string, and I need to avoid fetching all related posts of the same type.
Solution:
Use toolset_get_related_post( $post_id, 'relationship-slug' ) to retrieve the post ID tied specifically to the Post Reference Field; it returns the related post ID or 0 if none is found.
Example:
$related_post_id = toolset_get_related_post( 123, 'advisor' );
if ( $related_post_id ) {
echo 'Related post ID: ' . $related_post_id;
} else {
echo 'No related post found.';
}