0
votes

In brief, I am trying to effectively insert a PHP function into the shortcode and having no luck.

The shortcode:

[res_map address=""]

The function:

<?php the_field('address'); ?>

What I have so far:

<?php echo do_shortcode('[res_map address="' . the_field("address") . '"]'); ?>

Any help on how to properly do this will be highly appreciated.

1
The argument content has to be a string to search for shortcodes , what your the_field function returns ? - The Alpha

1 Answers

0
votes

You may try something like this

$ret = the_field("address");
echo do_shortcode('[res_map address = "'. $ret .'"]');

In this case, your function must return a string, i.e.

function the_field($arg)
{
    // ... 
    return 'something';
}

Because do_shortcode function expects string as it's argument and it's required. For example, it should be something like this

echo do_shortcode('[res_map address = "something"]');