Skip Navigation

Cannot use types shortcode as HTML attribute value in Maps pop-up

Won't fix

Topic Tags: Toolset Maps

Symptoms

Map pop-ups accept HTML markup for their content, and shortcodes can be used to output field values.

But it is not possible to use a shortcode to provide the value for an HTML attribute, e.g. this won’t work:

<a href="[types field='link-url'][/types]">Link...</a>

Workaround

A solution would be to register a custom shortcode that generates the HTML element as required, e.g.

add_shortcode('custom-link', function () {

    global $post;
    $url = get_post_meta( $post->ID, 'wpcf-custom-url', true );

    $output = "<a href='$url'>Link to $post->post_title</a>";

    return $output;
});

Then you could use that to output the whole link tag:

[custom-link]

Leave
a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>