Following the example in this issue:
https://wordpress.stackexchange.com/questions/291524/inserting-html-tag-with-acf-into-shortcode
I installed the (free) plugin “Code Snippets” on my WordPress.com site:
https://wordpress.org/plugins/code-snippets/
I created a new snippet.
The code snippet below creates a new shortcode called “[my_special_link]” that takes two parameters:
1. acf_link_field : the ACF field name you want to call on (assuming it’s a link type field)
2. text_value : the text you want to hyperlink on top of
[my_special_link acf_link_field="example_page_link" text_value="Whatever I want"]
This adds the text “Whatever I want” to the page and hyperlinks it to the ACF field link at field=example_page_link.
You could adapt this code to chain together however many ACF fields you wanted.
. . .
Title: ACF Link Field PLUS Text Value
Code:
<?php
function my_shortcode( $atts ) {
$atts = shortcode_atts( array(
'acf_link_field' => '', // Default value.
'text_value' => '', // Default value.
), $atts );
$output = '[acf field=' . $atts['acf_link_field'] . ']' ;
$output = do_shortcode( $output );
$output = '<a href="' . $output . '">' . $atts['text_value'] . '</a>';
return $output;
}
add_shortcode('my_special_link', 'my_shortcode');