2

So I have a php variable: $site= $your_name->getName("dfd_Name");

I have the following shortcode: <?php echo do_shortcode('[my_site dfd_Name=" "]'); ?>

What is the best way to put the $site variable into the dfd_Name=" " ? (something like dfd_Name="$site")

Thanks!

3 Answers 3

2
<?php echo do_shortcode('[my_site dfd_Name="'.$site.'"]'); ?>

Which in a neat form would look like this

<?php
  echo do_shortcode( '[my_site dfd_Name="'. $site .'"]' );
?>

It can also be

<?= do_shortcode( '[my_site dfd_Name="'. $site .'"]' ); ?>

It can also be

<?php
 $sc= '[my_site dfd_Name="'. $your_name->getName("dfd_Name") .'"]';
 echo do_shortcode($sc);
?>
Sign up to request clarification or add additional context in comments.

Comments

2

Shortest way would be with short tag:

<?= do_shortcode('[my_site dfd_Name="'.$site.'"]'); ?>

Comments

1

This one you can check :

<?php
    echo do_shortcode('[my_site dfd_Name="' . $site . '"]');
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.